smif.cli package

Module contents

A command line interface to the system of systems framework

This command line interface implements a number of methods.

  • setup creates a new project folder structure in a location
  • 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

Folder structure

When configuring a system-of-systems model for the CLI, the folder structure below should be used. In this example, there is one sector model, called water_supply:

/main_config.yaml
/timesteps.yaml
/water_supply.yaml
/data/all/inputs.yaml
/data/water_supply/
/data/water_supply/inputs.yaml
/data/water_supply/outputs.yaml
/data/water_supply/assets/assets1.yaml
/data/water_supply/planning/
/data/water_supply/planning/pre-specified.yaml

The data folder contains one subfolder for each sector model.

The sector model implementations can be installed independently of the model run configuration. The main_config.yaml file specifies which sector models should run, while each set of sector model config

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:
  • 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.execute_model_run(args)[source]

Runs the model run

Parameters:args
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, narratives)[source]

Load the narrative data from the sos model run configuration

Parameters:
Returns:

A list of smif.parameter.Narrative objects populated with data

Return type:

list

smif.cli.list_model_runs(args)[source]

List the model runs defined in the config

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.main(arguments=None)[source]

Parse args and run

smif.cli.parse_arguments()[source]

Parse command line arguments

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

Sets up the configuration files into the defined project folder

smif.cli.setup_project_folder(project_path)[source]

Creates folder structure in the target directory

Parameters:project_path (str) – Absolute path to an empty folder