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
/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.
- smif.cli.before_step(args)[source]¶
Prepare a single model to run (call once before calling smif step)
- Parameters:
args
- 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.csv2parquet(args)[source]¶
Convert CSV to Parquet - assuming the CSV can be parsed as a dataframe
- smif.cli.list_available_results(args)[source]¶
List the available results for a specified model run.
- smif.cli.list_model_runs(args)[source]¶
List the model runs defined in the config, optionally indicating whether complete results exist.
- smif.cli.prepare_model_runs(args)[source]¶
Generate multiple model runs according to a model run file referencing a scenario with multiple variants.
- smif.cli.prepare_scenario(args)[source]¶
Update scenario configuration file to include multiple scenario variants.
The initial scenario configuration file is overwritten.
- smif.cli.run(args)[source]¶
Run the model runs as requested. Check if results exist and asks user for permission to overwrite
- Parameters:
args