MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / set

Method set

monai/bundle/config_parser.py:412–432  ·  view source on GitHub ↗

Set config by ``id``. Args: config: config to set at location ``id``. id: id to specify the expected position. See also :py:meth:`__setitem__`. recursive: if the nested id doesn't exist, whether to recursively create the nested items in the confi

(self, config: Any, id: str = "", recursive: bool = True)

Source from the content-addressed store, hash-verified

410 return default
411
412 def set(self, config: Any, id: str = "", recursive: bool = True) -> None:
413 """
414 Set config by ``id``.
415
416 Args:
417 config: config to set at location ``id``.
418 id: id to specify the expected position. See also :py:meth:`__setitem__`.
419 recursive: if the nested id doesn't exist, whether to recursively create the nested items in the config.
420 default to `True`. for the nested id, only support `dict` for the missing section.
421
422 """
423 keys = ReferenceResolver.split_id(id)
424 conf_ = self.get()
425 if recursive:
426 if conf_ is None:
427 self.config = conf_ = {} # type: ignore
428 for k in keys[:-1]:
429 if isinstance(conf_, dict) and k not in conf_:
430 conf_[k] = {}
431 conf_ = conf_[k if isinstance(conf_, dict) else int(k)]
432 self[ReferenceResolver.normalize_id(id)] = self.ref_resolver.normalize_meta_id(config)
433
434 def update(self, pairs: dict[str, Any]) -> None:
435 """

Callers 7

__init__Method · 0.95
read_metaMethod · 0.95
read_configMethod · 0.95
test_config_contentMethod · 0.95
test_parseMethod · 0.95
__getitem__Method · 0.80

Calls 4

getMethod · 0.95
split_idMethod · 0.80
normalize_idMethod · 0.80
normalize_meta_idMethod · 0.80

Tested by 2

test_config_contentMethod · 0.76
test_parseMethod · 0.76