hydromt_wflow.utils.set_config#
- set_config(config: dict, key: str, value: Any)[source]#
Update a nested configuration dictionary using a dotted key path.
This function modifies a configuration dictionary in-place, allowing assignment to nested keys using dot-separated paths (e.g.
"a.b.c").- Parameters:
- Returns:
The updated configuration dictionary.
- Return type:
Examples
>>> from hydromt_wflow.utils import set_config >>> cfg = {"model": {"params": {"scale": 1.0, "offset": 0.0}}} >>> set_config(cfg, "model.params.scale", 2.5) {'model': {'params': {'scale': 2.5, 'offset': 0.0}}} You can also create nested keys if they do not exist: >>> set_config(cfg, "model.runtime.threads", 8) {'model': {'params': {'scale': 2.5, 'offset': 0.0}, 'runtime': {'threads': 8}}} Updating a top-level key works the same way: >>> set_config(cfg, "description", "Wflow test run") {'model': {'params': {'scale': 2.5, 'offset': 0.0}, 'runtime': {'threads': 8}}, 'description': 'Wflow test run'}