commonpower.benchmark.storage.BenchmarkFileStorage
- class BenchmarkFileStorage[source]
Bases:
BenchmarkStorageA class that provides methods to save and load benchmark scenarios to/from files.
- None
- save(benchmark_identifier
str, serialized_scenario: str, uri: Path) -> None: Saves the serialized scenario to a file at the specified URI.
- load(uri
Path) -> str: Loads a serialized scenario from the file at the specified URI and returns it as a string.
- handle_data_sources(system_node
System, uri: Path) -> None: Prepare all data sources for the benchmark scenario.
Methods
Store all data sources used in the system node as CSV files in the specified data folder.
Loads a serialized scenario from the file at the specified URI and returns it as a string.
Saves the serialized scenario to a file at the specified filepath (URI).
- handle_data_sources(system_node: System, uri: Path) None[source]
Store all data sources used in the system node as CSV files in the specified data folder.
- Parameters:
system_node (System) – The system node containing the data sources.
uri (Path) – The URI specifying the location where the data sources should be stored.
- Returns:
None
- load(uri: Path) str[source]
Loads a serialized scenario from the file at the specified URI and returns it as a string.
- Parameters:
uri (Path) – The URI specifying the location of the file to be loaded.
- Returns:
str – The loaded serialized scenario.
- Raises:
FileNotFoundError – If the data folder does not exist at the expected location.
ValueError – If the specified benchmark file is not a JSON file.
- save(benchmark_identifier: str, serialized_scenario: str, uri: Path) Path[source]
Saves the serialized scenario to a file at the specified filepath (URI).
- Parameters:
benchmark_identifier (str) – The desired filename for the benchmark.
serialized_scenario (str) – The serialized scenario to be saved, as returned by jsonpickle.
uri (Path) – The URI specifying the location where the file should be saved.
- Returns:
file_path (Path) – The path to the saved file.