finegrained_config
TOC
- Attributes:
- 🅰 ArgType
- Functions:
- 🅵 _get_info_dict - Retrieve configuration dictionary based on index.
- 🅵 _check_info - Validate configuration info dictionary.
- 🅵 _get_rcv_snd - Retrieve receive and send parameter configurations for a module.
- 🅵 _to_list
- 🅵 _construct_kwargs - Construct keyword arguments for module initialization.
- 🅵 enable_finegrained_config - Enable fine-grained configuration functionality.
- Classes:
- 🅲 FinegrainedConfig - Fine-grained configuration hook for handling parameter passing and hierarchical config.
Attributes
🅰 ArgType
ArgType = Union[int, float, bool, str, list, dict]
Functions
🅵 _get_info_dict
_get_info_dict
def _get_info_dict(index: str, config: ConfigDict) -> dict | None:
if not index.startswith("$"):
return config.pop(index, None)
for idx in index[1:].split("::"):
if not (config := config.pop(idx, None)):
raise CoreConfigParseError(f"{index}")
return config
Retrieve configuration dictionary based on index.
This function checks if the index starts with "$", indicating a hierarchical path. If so, it splits the index and traverses the configuration dictionary accordingly. If the index does not start with "$", it directly attempts to retrieve the value from the configuration dictionary.
Parameters:
- index (str): The index key to retrieve the configuration.
- config (ConfigDict): The configuration dictionary to search within.
Returns:
Raises:
- CoreConfigParseError: If the indexed configuration path does not exist.
Examples:
>>> config = {"a": {"b": {"c": 42}}} # Loaded toml config
>>> _get_info_dict("$a::b::c", config)
42