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.

Submodules:

Functions:

confirm Prompts for a yes or no response from the user
list_model_runs List the model runs defined in the config
main Parse args and run
parse_arguments Parse command line arguments
run_app Run the client/server application
run_model_runs Run the model runs as requested.
setup_project_folder Setup a sample project

Data:

USE_WIN32 bool(x) -> bool

Reference

smif.cli.confirm(prompt=None, response=False)[source]

Prompts for a yes or no response from the user

Parameters:
  • prompt (str, default=None) –
  • response (bool, default=False) –
Returns:

True for yes and False for no.

Return type:

bool

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.list_model_runs(args)[source]

List the model runs defined in the config

smif.cli.main(arguments=None)[source]

Parse args and run

smif.cli.parse_arguments()[source]

Parse command line arguments

Returns:
Return type:argparse.ArgumentParser
smif.cli.run_app(args)[source]

Run the client/server application

Parameters:args
smif.cli.run_model_runs(args)[source]

Run the model runs as requested. Check if results exist and asks user for permission to overwrite

Parameters:args
smif.cli.setup_project_folder(args)[source]

Setup a sample project