smif.cli package¶
A command line interface to the system of systems framework
This command line interface implements a number of methods.
- setup creates an example project with the recommended folder structure
- run performs a simulation of an individual sector model, or the whole system
- of systems model
- validate performs a validation check of the configuration file
- app runs the graphical user interface, opening in a web browser
Folder structure¶
When configuring a project for the CLI, the folder structure below should be used. In this example, there is one system-of-systems model, combining a water supply and an energy demand model:
/config
project.yaml
/sector_models
energy_demand.yml
water_supply.yml
/sos_models
energy_water.yml
/sos_model_runs
run_to_2050.yml
short_test_run.yml
...
/data
/initial_conditions
reservoirs.yml
/interval_definitions
annual_intervals.csv
/interventions
water_supply.yml
/narratives
high_tech_dsm.yml
/region_definitions
/oxfordshire
regions.geojson
/uk_nations_shp
regions.shp
/scenarios
population.csv
raininess.csv
/water_supply
/initial_system
/models
energy_demand.py
water_supply.py
/planning
expected_to_2020.yaml
national_infrastructure_pipeline.yml
The sector model implementations can be installed independently of the model run
configuration. The paths to python wrapper classes (implementing SectorModel)
should be specified in each sector_model/*.yml
configuration.
The project.yaml file specifies the metadata shared by all elements of the
project; sos_models
specify the combinations of sector_models
and
scenarios
while individual model_runs
specify the scenario, strategy
and narrative combinations to be used in each run of the models.
Functions:
build_model_run |
Builds the model run |
confirm |
Prompts for a yes or no response from the user |
execute_model_run |
Runs the model run |
get_model_run_definition |
Builds the model run |
get_narratives |
Load the narrative data from the sos model run configuration |
list_model_runs |
List the model runs defined in the config |
load_interval_sets |
Loads the time-interval sets into the project registries |
load_region_sets |
Loads the region sets into the project registries |
main |
Parse args and run |
make_get_data_interface |
Use args to make a function returning a suitable DataInterface |
parse_arguments |
Parse command line arguments |
run_app |
Run the client/server application |
setup_project_folder |
Creates folder structure in the target directory |
Reference¶
-
smif.cli.
build_model_run
(model_run_config)[source]¶ Builds the model run
Parameters: model_run_config (dict) – A valid model run configuration dict with objects Returns: Return type: smif.modelrun.ModelRun
-
smif.cli.
confirm
(prompt=None, response=False)[source]¶ Prompts for a yes or no response from the user
Parameters: Returns: True for yes and False for no.
Return type: Notes
response should be set to the default value assumed by the caller when user simply types ENTER.
Examples
>>> confirm(prompt='Create Directory?', response=True) Create Directory? [y]|n: True >>> confirm(prompt='Create Directory?', response=False) Create Directory? [n]|y: False >>> confirm(prompt='Create Directory?', response=False) Create Directory? [n]|y: y True
-
smif.cli.
get_model_run_definition
(args)[source]¶ Builds the model run
Returns: The complete sos_model_run configuration dictionary with contained ScenarioModel, SosModel and SectorModel objects Return type: dict
-
smif.cli.
get_narratives
(handler, narrative_config)[source]¶ Load the narrative data from the sos model run configuration
Parameters: - handler (
smif.data_layer.DataInterface
) – - narrative_config (dict) – A dict with keys as narrative_set names and values as narrative names
Returns: A list of
smif.parameter.Narrative
objects populated with dataReturn type: - handler (
-
smif.cli.
load_interval_sets
(handler)[source]¶ Loads the time-interval sets into the project registries
Parameters: handler ( smif.data_layer.DataInterface
) –
-
smif.cli.
load_region_sets
(handler)[source]¶ Loads the region sets into the project registries
Parameters: handler ( smif.data_layer.DataInterface
) –
-
smif.cli.
make_get_data_interface
(args)[source]¶ Use args to make a function returning a suitable DataInterface
-
smif.cli.
parse_arguments
()[source]¶ Parse command line arguments
Returns: Return type: argparse.ArgumentParser