Skip to content

Commit 70d51f6

Browse files
committed
MyPy on Git is complaining things that are not found in local checking.
Signed-off-by: mmelqin <mingmelvinq@nvidia.com>
1 parent 2b1b6fd commit 70d51f6

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

monai/deploy/operators/monai_bundle_inference_operator.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ def _ensure_str_list(config_names):
189189
self.config_names: List[str] = _ensure_str_list(config_names)
190190

191191

192+
DEFAULT_BundleConfigNames = BundleConfigNames()
193+
192194
# The operator env decorator defines the required pip packages commonly used in the Bundles.
193195
# The MONAI Deploy App SDK packager currently relies on the App to consolidate all required packages in order to
194196
# install them in the MAP Docker image.
@@ -222,22 +224,22 @@ class MonaiBundleInferenceOperator(InferenceOperator):
222224
a pickle file whose name is the same as the output name.
223225
"""
224226

225-
DISALLOWED_TRANSFORMS = ["LoadImage", "SaveImage"]
226-
227227
known_io_data_types = {
228228
"image": Image, # Image object
229229
"series": np.ndarray,
230230
"tuples": np.ndarray,
231231
"probabilities": Dict[str, Any], # dictionary containing probabilities and predicted labels
232232
}
233233

234+
kw_preprocessed_inputs = "preprocessed_inputs"
235+
234236
def __init__(
235237
self,
236238
input_mapping: List[IOMapping],
237239
output_mapping: List[IOMapping],
238240
model_name: Optional[str] = "",
239-
bundle_path: Optional[str] = None,
240-
bundle_config_names: Optional[BundleConfigNames] = None,
241+
bundle_path: Optional[str] = "",
242+
bundle_config_names: Optional[BundleConfigNames] = DEFAULT_BundleConfigNames,
241243
*args,
242244
**kwargs,
243245
):
@@ -391,7 +393,7 @@ def _get_meta_key_postfix(self, compose: Compose, key_name: str = "meta_key_post
391393
post_fix = getattr(t, key_name)
392394
# For some reason the attr is a tuple
393395
if isinstance(post_fix, tuple):
394-
post_fix = post_fix[0]
396+
post_fix = str(post_fix[0])
395397
break
396398

397399
return str(post_fix)
@@ -496,7 +498,8 @@ def compute(self, op_input: InputContext, op_output: OutputContext, context: Exe
496498
# TODO: Does this work for models where multiple outputs are returned?
497499
# Note that the inputs are needed because the invert transform requires it.
498500
start = time.time()
499-
outputs = self.post_process(ensure_tuple(outputs)[0], preprocessed_inputs=inputs)
501+
kw_args = {self.kw_preprocessed_inputs: inputs}
502+
outputs = self.post_process(ensure_tuple(outputs)[0], **kw_args)
500503
logging.debug(f"Post-processing elapsed time (seconds): {time.time() - start}")
501504
if isinstance(outputs, (tuple, list)):
502505
output_dict = dict(zip(self._outputs.keys(), outputs))
@@ -530,7 +533,7 @@ def post_process(self, data: Any, *args, **kwargs) -> Union[Image, Any, Tuple[An
530533
"""
531534

532535
# Expect the inputs be passed in so that the inversion can work.
533-
inputs = kwargs.get("preprocessed_inputs", {})
536+
inputs = kwargs.get(self.kw_preprocessed_inputs, {})
534537

535538
if is_map_compose(self._postproc):
536539
if isinstance(data, (list, tuple)):

0 commit comments

Comments
 (0)