Loads a YAML file and its base_configs recursively using OmegaConf.
(config_name: str)
| 75 | |
| 76 | |
| 77 | def _load_config(config_name: str) -> omegaconf.DictConfig: |
| 78 | """Loads a YAML file and its base_configs recursively using OmegaConf.""" |
| 79 | cfg = omegaconf.OmegaConf.load(config_name) |
| 80 | if _BASE_CONFIG_ATTR in cfg: |
| 81 | base_path = cfg[_BASE_CONFIG_ATTR] |
| 82 | if not os.path.isabs(base_path): |
| 83 | # Search relative to current config, then in the default configs folder |
| 84 | loaded_parent_config_filename = os.path.join(os.path.dirname(config_name), base_path) |
| 85 | if not os.path.isfile(loaded_parent_config_filename): |
| 86 | dir_path = os.path.dirname(os.path.realpath(__file__)) |
| 87 | loaded_parent_config_filename = os.path.join(dir_path, "configs", base_path) |
| 88 | else: |
| 89 | loaded_parent_config_filename = base_path |
| 90 | |
| 91 | base_cfg = _load_config(loaded_parent_config_filename) |
| 92 | cfg = omegaconf.OmegaConf.merge(base_cfg, cfg) |
| 93 | return cfg |
| 94 | |
| 95 | |
| 96 | def _tuples_to_lists(l: list | tuple | Any) -> list | Any: |
no outgoing calls
no test coverage detected