modelrunner.config module

Handles configuration variables.

Config

Class handling the package configuration.

class Config(default=None, mode='update', *, check_validity=True, include_deprecated=True)[source]

Bases: UserDict

Class handling the package configuration.

Parameters:
  • default (sequence of Parameter, optional) – Default configuration values. The default configuration also defines what parameters can typically be defined and it provides additional information for these parameters.

  • mode (str) –

    Defines the mode in which the configuration is used. Possible values are

    • insert: any new configuration key can be inserted

    • update: only the values defined by default can be updated

    • locked: no values can be changed

    Note that the items specified by items will always be inserted, independent of the mode.

  • check_validity (bool) – Determines whether a ValueError is raised if there are keys in parameters that are not in the defaults. If False, additional items are simply stored in self.parameters

  • include_deprecated (bool) – Include deprecated parameters

copy()[source]

Return a copy of the configuration.

Return type:

Config

load(path)[source]

Load configuration from yaml file.

Parameters:

path (str | Path)

save(path)[source]

Save configuration to yaml file.

Parameters:

path (str | Path)

to_dict()[source]

Convert the configuration to a simple dictionary.

Returns:

A representation of the configuration in a normal dict.

Return type:

dict