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

Method get_item

monai/bundle/reference_resolver.py:89–105  ·  view source on GitHub ↗

Get the ``ConfigItem`` by id. If ``resolve=True``, the returned item will be resolved, that is, all the reference strings are substituted by the corresponding ``ConfigItem`` objects. Args: id: id of the expected config item. resolve: whether

(self, id: str, resolve: bool = False, **kwargs: Any)

Source from the content-addressed store, hash-verified

87 self.items[id] = item
88
89 def get_item(self, id: str, resolve: bool = False, **kwargs: Any) -> ConfigItem | None:
90 """
91 Get the ``ConfigItem`` by id.
92
93 If ``resolve=True``, the returned item will be resolved, that is,
94 all the reference strings are substituted by the corresponding ``ConfigItem`` objects.
95
96 Args:
97 id: id of the expected config item.
98 resolve: whether to resolve the item if it is not resolved, default to False.
99 kwargs: keyword arguments to pass to ``_resolve_one_item()``.
100 Currently support ``instantiate`` and ``eval_expr``. Both are defaulting to True.
101 """
102 id = self.normalize_id(id)
103 if resolve and id not in self.resolved_content:
104 self._resolve_one_item(id=id, **kwargs)
105 return self.items.get(id)
106
107 def _resolve_one_item(
108 self, id: str, waiting_list: set[str] | None = None, **kwargs: Any

Callers 2

test_resolveMethod · 0.95

Calls 3

normalize_idMethod · 0.95
_resolve_one_itemMethod · 0.95
getMethod · 0.80

Tested by 1

test_resolveMethod · 0.76