Skip to content

Commit 14fcf72

Browse files
authored
Improve ConfigParser documentation (#7058)
Fixes #7057 ### Description Improve the usage of `ConfigParser` methods `read_config`, `load_config_file`, `load_config_files`. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: KumoLiu <yunl@nvidia.com>
1 parent 84566d1 commit 14fcf72

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

monai/bundle/config_parser.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ def read_meta(self, f: PathLike | Sequence[PathLike] | dict, **kwargs: Any) -> N
305305

306306
def read_config(self, f: PathLike | Sequence[PathLike] | dict, **kwargs: Any) -> None:
307307
"""
308-
Read the config from specified JSON or YAML file.
309-
The config content in the `self.config` dictionary.
308+
Read the config from specified JSON/YAML file or a dictionary and
309+
override the config content in the `self.config` dictionary.
310310
311311
Args:
312312
f: filepath of the config file, the content must be a dictionary,
@@ -383,7 +383,7 @@ def _do_parse(self, config: Any, id: str = "") -> None:
383383
@classmethod
384384
def load_config_file(cls, filepath: PathLike, **kwargs: Any) -> dict:
385385
"""
386-
Load config file with specified file path (currently support JSON and YAML files).
386+
Load a single config file with specified file path (currently support JSON and YAML files).
387387
388388
Args:
389389
filepath: path of target file to load, supported postfixes: `.json`, `.yml`, `.yaml`.
@@ -405,13 +405,15 @@ def load_config_file(cls, filepath: PathLike, **kwargs: Any) -> dict:
405405
@classmethod
406406
def load_config_files(cls, files: PathLike | Sequence[PathLike] | dict, **kwargs: Any) -> dict:
407407
"""
408-
Load config files into a single config dict.
408+
Load multiple config files into a single config dict.
409409
The latter config file in the list will override or add the former config file.
410410
``"::"`` (or ``"#"``) in the config keys are interpreted as special characters to go one level
411411
further into the nested structures.
412412
413413
Args:
414414
files: path of target files to load, supported postfixes: `.json`, `.yml`, `.yaml`.
415+
if providing a list of files, wil merge the content of them.
416+
if providing a dictionary, return it directly.
415417
kwargs: other arguments for ``json.load`` or ```yaml.safe_load``, depends on the file format.
416418
"""
417419
if isinstance(files, dict): # already a config dict

0 commit comments

Comments
 (0)