Skip to content

Commit a96b680

Browse files
Fix minor issues in monai_bundle_inference_operator.py
- Corrected the bundle suffixes tuple to include a period before 'yml'. - Fixed a method call to ensure casefold() is invoked correctly. - Initialized meta_data to an empty dictionary if not provided. These changes enhance code clarity and prevent potential runtime errors.
1 parent ce30e9a commit a96b680

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

monai/deploy/operators/monai_bundle_inference_operator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def get_bundle_config(bundle_path, config_names):
186186
Gets the configuration parser from the specified Torchscript bundle file path.
187187
"""
188188

189-
bundle_suffixes = (".json", ".yaml", "yml") # The only supported file ext(s)
189+
bundle_suffixes = (".json", ".yaml", ".yml") # The only supported file ext(s)
190190
config_folder = "extra"
191191

192192
def _read_from_archive(archive, root_name: str, config_name: str, do_search=True):
@@ -216,7 +216,7 @@ def _read_from_archive(archive, root_name: str, config_name: str, do_search=True
216216
name_list = archive.namelist()
217217
for suffix in bundle_suffixes:
218218
for n in name_list:
219-
if (f"{config_name}{suffix}").casefold in n.casefold():
219+
if (f"{config_name}{suffix}").casefold() in n.casefold():
220220
logging.debug(f"Trying to read content of config {config_name!r} from {n!r}.")
221221
content_text = archive.read(n)
222222
break
@@ -745,6 +745,7 @@ def compute(self, op_input, op_output, context):
745745
# value: NdarrayOrTensor # MyPy complaints
746746
value, meta_data = self._receive_input(name, op_input, context)
747747
value = convert_to_dst_type(value, dst=value)[0]
748+
meta_data = meta_data or {}
748749
if not isinstance(meta_data, dict):
749750
raise ValueError("`meta_data` must be a dict.")
750751
value = MetaTensor.ensure_torch_and_prune_meta(value, meta_data)

0 commit comments

Comments
 (0)