espnet3.bin.atlas.core.utils.split_patch_by_search_space
Less than 1 minute
espnet3.bin.atlas.core.utils.split_patch_by_search_space
espnet3.bin.atlas.core.utils.split_patch_by_search_space(patch: dict, search_space) → tuple[dict, list[str]]
Split a config patch into allowed keys and keys the search space rules out.
A key is dropped when it matches any denied_keys pattern, or when allowed_keys is set and it matches none of its patterns. Patterns are fnmatch globs over the dotted key, for example optimizer.*.
- Parameters:
- patch – Dotted config keys mapped to new values.
- search_space – The
atlas.search_spaceconfig node (allowed_keysanddenied_keysare both optional).
- Returns: The allowed part of
patchand the removed keys. - Return type: tuple[dict, list[str]]
Example
>>> space = {"allowed_keys": ["optimizer.*"], "denied_keys": []}
>>> split_patch_by_search_space({"optimizer.lr": 1, "trainer.x": 2}, space)
({'optimizer.lr': 1}, ['trainer.x'])