nemo_rl.utils.config
#
Module Contents#
Functions#
Resolve a path relative to the base path. |
|
Load a config file with inheritance support. |
|
Load a config file with inheritance support and convert it to an OmegaConf object. |
|
Parse and apply Hydra overrides to an OmegaConf config. |
API#
- nemo_rl.utils.config.resolve_path(base_path: pathlib.Path, path: str) pathlib.Path [source]#
Resolve a path relative to the base path.
- nemo_rl.utils.config.load_config_with_inheritance(
- config_path: Union[str, pathlib.Path],
- base_dir: Optional[Union[str, pathlib.Path]] = None,
Load a config file with inheritance support.
- Parameters:
config_path β Path to the config file
base_dir β Base directory for resolving relative paths. If None, uses config_pathβs directory
- Returns:
Merged config dictionary
- nemo_rl.utils.config.load_config(
- config_path: Union[str, pathlib.Path],
Load a config file with inheritance support and convert it to an OmegaConf object.
The config inheritance system supports:
Single inheritance:
# child.yaml defaults: parent.yaml common: value: 43
Multiple inheritance:
# child.yaml defaults: - parent1.yaml - parent2.yaml common: value: 44
Nested inheritance:
# parent.yaml defaults: grandparent.yaml common: value: 43 # child.yaml defaults: parent.yaml common: value: 44
Variable interpolation:
# parent.yaml base_value: 42 derived: value: ${base_value} # child.yaml defaults: parent.yaml base_value: 43 # This will update both base_value and derived.value
The system handles:
Relative and absolute paths
Multiple inheritance
Nested inheritance
Variable interpolation
The inheritance is resolved depth-first, with later configs overriding earlier ones. This means in multiple inheritance, the last config in the list takes precedence.
- Parameters:
config_path β Path to the config file
- Returns:
Merged config dictionary
- exception nemo_rl.utils.config.OverridesError[source]#
Bases:
Exception
Custom exception for Hydra override parsing errors.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- nemo_rl.utils.config.parse_hydra_overrides(
- cfg: omegaconf.DictConfig,
- overrides: list[str],
Parse and apply Hydra overrides to an OmegaConf config.
- Parameters:
cfg β OmegaConf config to apply overrides to
overrides β List of Hydra override strings
- Returns:
Updated config with overrides applied
- Raises:
OverridesError β If thereβs an error parsing or applying overrides