MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / load_config_files

Method load_config_files

monai/bundle/config_parser.py:614–638  ·  view source on GitHub ↗

Load multiple config files into a single config dict. The latter config file in the list will override or add the former config file. ``"::"`` (or ``"#"``) in the config keys are interpreted as special characters to go one level further into the nested structures.

(cls, files: PathLike | Sequence[PathLike] | dict, **kwargs: Any)

Source from the content-addressed store, hash-verified

612
613 @classmethod
614 def load_config_files(cls, files: PathLike | Sequence[PathLike] | dict, **kwargs: Any) -> dict:
615 """
616 Load multiple config files into a single config dict.
617 The latter config file in the list will override or add the former config file.
618 ``"::"`` (or ``"#"``) in the config keys are interpreted as special characters to go one level
619 further into the nested structures.
620
621 Args:
622 files: path of target files to load, supported postfixes: `.json`, `.yml`, `.yaml`.
623 if providing a list of files, will merge the content of them.
624 if providing a string with comma separated file paths, will merge the content of them.
625 if providing a dictionary, return it directly.
626 kwargs: other arguments for ``json.load`` or ```yaml.safe_load``, depends on the file format.
627 """
628 if isinstance(files, dict): # already a config dict
629 return files
630 parser = ConfigParser(config={})
631 if isinstance(files, str) and not Path(files).is_file() and "," in files:
632 files = files.split(",")
633 for i in ensure_tuple(files):
634 config_dict = cls.load_config_file(i, **kwargs)
635 for k, v in config_dict.items():
636 merge_kv(parser, k, v)
637
638 return parser.get() # type: ignore
639
640 @classmethod
641 def export_config_file(cls, config: dict, filepath: PathLike, fmt: str = "json", **kwargs: Any) -> None:

Callers 5

read_metaMethod · 0.95
read_configMethod · 0.95
verify_metadataFunction · 0.80
__init__Method · 0.80
test_load_configsMethod · 0.80

Calls 6

getMethod · 0.95
ensure_tupleFunction · 0.90
merge_kvFunction · 0.90
ConfigParserClass · 0.85
splitMethod · 0.80
load_config_fileMethod · 0.80

Tested by 1

test_load_configsMethod · 0.64