hydromt_wflow.WflowModel.set_config#
- WflowModel.set_config(*args)[source]#
Update the config toml at key(s) with values.
This function is made to maintain the structure of your toml file. When adding keys it will look for the most specific header present in the toml file and add it under that.
meaning that if you have a config toml that is empty and you run
wflow_model.set_config("input.forcing.scale", 1)
it will result in the following file:
input.forcing.scale = 1
however if your toml file looks like this before:
[input.forcing]
(i.e. you have a header in there that has no keys)
then after the insertion it will look like this:
[input.forcing] scale = 1
Warning
Due to limitations of the underlying library it is currently not possible to create new headers (i.e. groups like
input.forcing
in the example above) programmatically, and they will need to be added to the default config toml document- Parameters:
args (str, tuple, list) – if tuple or list, minimal length of two keys can given by multiple args: (‘key1’, ‘key2’, ‘value’) or a string with ‘.’ indicating a new level: (‘key1.key2’, ‘value’)
Examples
>> self.config >> {'a': 1, 'b': {'c': {'d': 2}}} >> self.set_config('a', 99) >> {'a': 99, 'b': {'c': {'d': 2}}} >> self.set_config('b', 'c', 'd', 99) # identical to set_config('b.d.e', 99) >> {'a': 1, 'b': {'c': {'d': 99}}}