espnet3.utils.config.load_yaml
Less than 1 minute
espnet3.utils.config.load_yaml
espnet3.utils.config.load_yaml(path, key=None)
Load a YAML file and optionally return a nested key.
This resolver is intended for pulling a single value from another config, e.g., ${load_yaml:conf/train.yaml,exp_tag}.
- Parameters:
- path (str or Path) – Path to the YAML file.
- key (str , optional) – Dot-delimited key to select.
- Returns: The selected value or the full config if key is None.
- Return type: Any
- Raises:
- FileNotFoundError – If
pathdoes not exist. - PermissionError – If the file cannot be read.
- KeyError – If
keyis provided but not present in the YAML.
- FileNotFoundError – If
Example
>>> from omegaconf import OmegaConf
>>> cfg = OmegaConf.create({"tag": "${load_yaml:conf/train.yaml,exp_tag}"})