rubem.configuration.model_configuration.ModelConfiguration
- class ModelConfiguration(config_input, validate_input=True, base_dir=None, allow_blocking_problems=False)[source]
-
Bases:
objectRepresents the configuration settings for the model.
The ModelConfiguration class is responsible for loading and storing the configuration settings required for running the model. It supports loading configuration from either a dictionary or a JSON file.
- Parameters:
-
config_input (
dict|str|PathLike[str] |bytes) – The configuration input: a dictionary with the legacy sections, or the path of a legacy JSON file. A dictionary is copied, so changing it after the load does not change the loaded configuration.validate_input (
bool) – Whether to validate the input files and their content. Defaults to True.base_dir (
str|PathLike[str] |bytes|None) – Directory the relative paths of the configuration are anchored on. Defaults to the directory of the JSON file, or toNone(paths kept as given) for a dictionary.allow_blocking_problems (
bool) – Whether to keep going when the inputs carry blocking problems: the checks still run and every problem is kept inproblems, the blocking ones are logged as errors and the configuration loads instead of raisingConfigurationError. Defaults toFalse.
- Raises:
-
FileNotFoundError – If the specified config file is not found.
ValueError – If the config file type is not supported, or a setting is missing or invalid (
pydantic.ValidationErroris aValueError).json.JSONDecodeError – If the JSON file is not valid.
ConfigurationError – If the inputs carry blocking problems, unless
allow_blocking_problemsis set.
Methods
Load a legacy configuration from a dictionary or a JSON file.
Write
metadata.jsonnext to the outputs of a format 1.0 run.- classmethod load(config_input, validate_input=True, base_dir=None, allow_blocking_problems=False)[source]
-
Load a legacy configuration from a dictionary or a JSON file.
Relative paths are anchored on the directory of the JSON file, or on
base_dirwhen given (a dictionary has no anchor unlessbase_diris passed).allow_blocking_problemsis passed through to the constructor.- Return type:
- write_metadata()[source]
-
Write
metadata.jsonnext to the outputs of a format 1.0 run.A no-op for a legacy configuration, which has no
metadatasection. Intended to be called once the run has finished successfully (after every other output has been written): it is not called while loading or validating the configuration, so a configuration that fails validation never touches an existingmetadata.json. The write itself is atomic (a temporary file, replaced onto the target), so a failure while writing leaves an existingmetadata.jsonuntouched.- Return type:
-
None