ska_sdp_piper.piper.configurations.runtime_config module

class ska_sdp_piper.piper.configurations.runtime_config.RuntimeConfig(pipeline, parameters, global_parameters, version=None)[source]

Bases: object

Runtime configuration manager for the pipeline

Parameters:
  • pipeline (dict) -- Pipeline stages state configuration.

  • parameters (dict) -- Pipeline stages parameters configuration.

  • global_parameters (dict) -- Pipeline global parameters configuration.

set(config_path, value)[source]

Updates a given key in the config

Parameters:
  • config_path (str) -- Path to the key. This can represent a path to a nested key, where each key in the hirerarchy is seperated by a . character.

  • value (Any) -- Value to be update with.

Examples

>>> stage_params = {
        "stage1": {
            "param1": 10
        }
    }
>>> runtimeconfig = RuntimeConfig({"stage1": True}, stage_params, {})
>>> runtimeconfig.set("parameters.stage1.param1", 20)
>>> runtimeconfig.set("pipeline.stage1", False)
update_from_yaml(yaml_path)[source]

Updates current runtime configuration from a yaml file

Parameters:

yaml_path (str) -- Path to the yaml configuration file

Returns:

Same instance but with updated paramters.

Return type:

RuntimeConfig

update_from_cli_overrides(cli_overrides)[source]

Update the runtime configuration from CLI overrides option

Parameters:

cli_overrides (list[tuple[str, str]]) -- A list of tuple/list, where each element contains 2 sub-elements. First element is a string key to the parameter to override. This can represent a path to a nested key, where each key in the hirerarchy is seperated by a . character. Second element is also a string, which is then parsed using YAML rules, and converted to a rich object.

Returns:

Same instance but with updated paramters

Return type:

RuntimeConfig

Examples

>>> runtimeconfig.update_from_cli_overrides(
        ["parameters.stage1.param1", "20"],
        ["pipeline.stage1", "False"],
    )
update_from_cli_stages(cli_stages)[source]

Update the pipeline stage states

Parameters:

cli_stages (list[str]) -- Names of the stages to be enabled

Returns:

Same instance but with updated paramters

Return type:

RuntimeConfig

write_yml(path)[source]

Writes config to provided path in yaml format.

Parameters:

path (str) -- Location of config file to write to.

property stages_to_run: list[str]

Returns the list of names of stages which are enabled for this run.

Return type:

List of names of the stages to run.