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

Method _do_parse

monai/bundle/config_parser.py:568–589  ·  view source on GitHub ↗

Recursively parse the nested data in config source, add every item as `ConfigItem` to the resolver. Args: config: config source to parse. id: id of the ``ConfigItem``, ``"::"`` (or ``"#"``) in id are interpreted as special characters to go on

(self, config: Any, id: str = "")

Source from the content-addressed store, hash-verified

566 self.set(self._do_resolve(config=self.get()))
567
568 def _do_parse(self, config: Any, id: str = "") -> None:
569 """
570 Recursively parse the nested data in config source, add every item as `ConfigItem` to the resolver.
571
572 Args:
573 config: config source to parse.
574 id: id of the ``ConfigItem``, ``"::"`` (or ``"#"``) in id are interpreted as special characters to
575 go one level further into the nested structures.
576 Use digits indexing from "0" for list or other strings for dict.
577 For example: ``"xform::5"``, ``"net::channels"``. ``""`` indicates the entire ``self.config``.
578
579 """
580 if isinstance(config, (dict, list)):
581 for _, sub_id, v in self.ref_resolver.iter_subconfigs(id=id, config=config):
582 self._do_parse(config=v, id=sub_id)
583
584 if ConfigComponent.is_instantiable(config):
585 self.ref_resolver.add_item(ConfigComponent(config=config, id=id, locator=self.locator))
586 elif ConfigExpression.is_expression(config):
587 self.ref_resolver.add_item(ConfigExpression(config=config, id=id, globals=self.globals))
588 else:
589 self.ref_resolver.add_item(ConfigItem(config=config, id=id))
590
591 @classmethod
592 def load_config_file(cls, filepath: PathLike, **kwargs: Any) -> dict:

Callers 1

parseMethod · 0.95

Calls 7

ConfigComponentClass · 0.90
ConfigExpressionClass · 0.90
ConfigItemClass · 0.90
iter_subconfigsMethod · 0.80
is_instantiableMethod · 0.80
add_itemMethod · 0.80
is_expressionMethod · 0.80

Tested by

no test coverage detected