setup module

Read in the configuration YAMLs and prepare a self-consistent experiment configuration file.

clean_rocoto_dict(rocotodict)

Removes any invalid entries from rocotodict. Examples of invalid entries are:

  1. A task dictionary containing no “command” key

  2. A metatask definition dependent on a variable with no entries

  3. A metatask dictionary containing no task dictionaries

Parameters:

rocotodict (dict) – A dictionary containing Rocoto workflow settings

load_config_for_setup(ushdir, default_config_path, user_config_path)

Load in the default, machine, and user configuration files into Python dictionaries. Return the combined experiment dictionary.

Parameters:
  • ushdir (str) – Path to the ush directory for the SRW App

  • default_config (str) – Path to config_defaults.yaml

  • user_config (str) – Path to the user-provided config YAML (usually named config.yaml)

Returns:

The combined, schema-checked experiment Config object.

Raises:
  • FileNotFoundError – If the user-provided configuration file or the machine file does not exist.

  • Exception – If (1) the user-provided configuration file cannot be loaded or (2) it contains invalid sections/keys or (3) it does not contain mandatory information or (4) an invalid datetime format is used.

set_srw_paths(expt_config)

Generates a dictionary of directories that describe the SRW App structure, i.e., where the SRW App is installed and the paths to external repositories managed via the manage_externals tool.

Other paths for the SRW App are set as defaults in config_defaults.yaml.

Parameters:

expt_config (dict) – Contains the configuration settings for the user-defined experiment

Returns:

Dictionary of configuration settings and system paths as keys/values

Raises:
  • KeyError – If the external repository required is not listed in the externals configuration file (e.g., Externals.cfg)

  • FileNotFoundError – If the ufs-weather-model code containing the FV3 source code has not been cloned properly

setup(ushdir, user_config_fn='config.yaml', debug: bool = False)

Validates user-provided configuration settings and derives a secondary set of parameters needed to configure a Rocoto-based SRW App workflow. The secondary parameters are derived from a set of required parameters defined in config_defaults.yaml, a user-provided configuration file (e.g., config.yaml), or a YAML machine file.

A set of global variable definitions is saved to the experiment directory as a bash configure file that is sourced by scripts at run time.

Parameters:
  • ushdir (str) – The full path of the ush/ directory where this script (setup.py) is located

  • user_config_fn (str) – The name of a user-provided configuration YAML (usually config.yaml)

  • debug (bool) – Enable extra output for debugging

Returns:

None

Raises:
  • ValueError – If checked configuration values are invalid (e.g., forecast length, EXPTDIR path)

  • FileExistsError – If EXPTDIR already exists, and PREEXISTING_DIR_METHOD is not set to a compatible handling method

  • FileNotFoundError – If the path to a particular file does not exist or if the file itself does not exist at the expected path

  • TypeError – If USE_CUSTOM_POST_CONFIG_FILE or USE_CRTM are set to true but no corresponding custom configuration file or CRTM fix file directory is set

  • KeyError – If an invalid value is provided (i.e., for GRID_GEN_METHOD)