peal.global_utils.load_yaml_config¶
- peal.global_utils.load_yaml_config(config_path, config_model=None, return_namespace=True)[source]¶
Load a config file (or dict) into its pydantic model.
The central entry point used all over PEAL. The yaml is read with all path placeholders expanded and nested yamls inlined. If no
config_modelis given but the data identifies itself throughconfig_nameorcategory/<category>_type, the model is looked up withget_config_model(); a failure there is only warned about. With a model, nested dicts and lists of dicts are converted first, the model is instantiated andpropagate_seed()is run. Without one, the dict is either wrapped in aSimpleNamespaceor returned as is.- Parameters:
config_path (
strordictorobject) – Path of a.yamlfile, an already loaded dict, or a config object, which is passed through unchanged.config_model (
type, optional) – The pydantic class to instantiate; inferred when omitted.return_namespace (
bool, optional) – Wrap a model-less dict in atypes.SimpleNamespaceinstead of returning the plain dict. Set toFalsefor nested dicts, which pydantic wants to receive as dicts.
- Returns:
The config: an instance of
config_model, aSimpleNamespaceor the raw data.- Return type:
- Raises:
Exception – If
config_pathis a string that does not end in.yaml.