Configuration classes#
Configuration handler.
This script provides the base class to save the metadata for a given ReEDS scenario. It can either read the information directly or throught a cases file.
- class r2x.config.Configuration(scenarios=<factory>, scenario_names=<factory>)#
R2X configuration manager that wraps multiple Scenario instances.
This class parses either the cases_*.csv file or reads the inputs from the CLI.
- scenario_list#
List of Scenario instances
See also
- classmethod from_cases(cases_fpath, cli_args, user_dict=None)#
Parse the legacy cases file into a list of Scenarios.
- Parameters:
- Raises:
FileNotFoundError – If csv file does not exists
- classmethod from_cli(cli_args, user_dict=None, **kwargs)#
Create scenario from the CLI arguments.
It saves the created scenario in the scenario_list` and scenario_names
- get(name)#
Return a scenario from the configuration manager.
- static override(params, cli_args, user_dict=None)#
Override scenario either by user provided dict or cli.
If the user want to override defaults it can be done by passing the user_dict. Currently, we only use the user_dict to override the defaults and the fmap.
- class r2x.config.Scenario(name=None, run_folder=None, output_folder=PosixPath('.'), solve_year=None, weather_year=None, input_model=None, output_model=None, cases_flags=<factory>, fmap=<factory>, defaults=<factory>, feature_flags=<factory>, plugins=None, _mkdir=True)#
Scenario class.
The purpose of the scenario class is to provide a way to track the inputs and defaults for a given translation. It serves as an access point to get the defaults, configuration and features flags for different steps (e.g., parser, exporter or validation) since most of the codebase use object composition.
Each scenario can have its own set of flags that will run different parts of the parsers.
A very simple use case for this class:
from r2x.config import Scenario scenario = Scenario(name="test") print(scenario)
- Parameters:
name (str | None) – Name for the scenario
run_folder (pathlib.Path | str | None) – Path for the scenario inputs
output_folder (pathlib.Path | str) – Path for output exports
input_model (str | None) – Model to translate from
output_model (str | None) – model to translate to
defaults (dict[str, Any]) – Default configuration from the scenario
feature_flags (dict[str, Any]) – Dictionary with experimental features
plugins (list[Any] | None) – List of plugins enabled
weather_year (int | None)
_mkdir (bool)
See also
- classmethod from_kwargs(**kwargs)#
Create Scenario instance from key arguments.
- Return type:
- info()#
Return table summary of the configuration.
- Return type:
None