hydromt.model.components.ConfigComponent#
- class hydromt.model.components.ConfigComponent(model: Model, *, filename: str = 'config.yaml', default_template_filename: str | None = None)[source]#
A component to manage configuration files for model simulations/settings.
ConfigComponent
data is stored as a dictionary and can be written to a file in yaml or toml format. The component can be used to store model settings and parameters that are used in the model simulations or in the model settings.Initialize a ConfigComponent.
- Parameters:
model (
Model
) – HydroMT model instancefilename (
str
) – A path relative to the root where the configuration file will be read and written if user does not provide a path themselves. By default ‘config.yml’default_template_filename (
Optional[Path]
) – A path to a template file that will be used as default in thecreate
method to initialize the configuration file if the user does not provide their own template file. This can be used by model plugins to provide a default configuration template. By default None.
- __init__(model: Model, *, filename: str = 'config.yaml', default_template_filename: str | None = None)[source]#
Initialize a ConfigComponent.
- Parameters:
model (
Model
) – HydroMT model instancefilename (
str
) – A path relative to the root where the configuration file will be read and written if user does not provide a path themselves. By default ‘config.yml’default_template_filename (
Optional[Path]
) – A path to a template file that will be used as default in thecreate
method to initialize the configuration file if the user does not provide their own template file. This can be used by model plugins to provide a default configuration template. By default None.
Methods
__init__
(model, *[, filename, ...])Initialize a ConfigComponent.
create
([template])Create a new config file based on a template file.
get_value
(key[, fallback, abs_path])Get a config value at key(s).
read
([path])Read model config at <root>/{path}.
set
(key, value)Update the config dictionary at key(s) with values.
test_equal
(other)Test if two components are equal.
update
(data)Set the config dictionary at key(s) with values.
write
([path])Write model config at <root>/{path}.
Attributes
Model config values.
Return the data catalog of the model this component is associated with.
Return the model object this component is associated with.
Return the root of the model this component is associated with.