MCPcopy Create free account
hub / github.com/AI-Hypercomputer/maxtext / _load_config

Function _load_config

src/MaxText/pyconfig.py:77–93  ·  view source on GitHub ↗

Loads a YAML file and its base_configs recursively using OmegaConf.

(config_name: str)

Source from the content-addressed store, hash-verified

75
76
77def _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
96def _tuples_to_lists(l: list | tuple | Any) -> list | Any:

Callers 1

initialize_pydanticFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected