Skip to content

Commit 40b75be

Browse files
committed
Fix mypy complaints for already migrated code.
Signed-off-by: M Q <mingmelvinq@nvidia.com>
1 parent df4cfba commit 40b75be

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

examples/apps/ai_livertumor_seg_app/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def compose(self):
8484
series_selector_op = DICOMSeriesSelectorOperator(self, rules=Sample_Rules_Text, name="series_selector_op")
8585
series_to_vol_op = DICOMSeriesToVolumeOperator(self, name="series_to_vol_op")
8686
# Model specific inference operator, supporting MONAI transforms.
87-
liver_tumor_seg_op = LiverTumorSegOperator(
88-
self, model_path=model_path, output_folder=app_output_path, name="seg_op"
89-
)
87+
liver_tumor_seg_op = LiverTumorSegOperator(self, model_path=model_path, name="seg_op")
88+
# self, model_path=model_path, output_folder=app_output_path, name="seg_op"
89+
# )
9090

9191
# Create the publisher operator
9292
stl_op = STLConversionOperator(self, output_file=app_output_path.joinpath("stl/mesh.stl"), name="stl_op")

examples/apps/ai_livertumor_seg_app/livertumor_seg_operator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import logging
1313
from pathlib import Path
14+
from typing import Optional
1415

1516
from numpy import uint8
1617

@@ -60,13 +61,15 @@ class LiverTumorSegOperator(Operator):
6061

6162
DEFAULT_OUTPUT_FOLDER = Path.cwd() / "saved_images_folder"
6263

63-
def __init__(self, frament: Fragment, *args, model_path: Path, output_folder: Path = None, **kwargs):
64+
def __init__(
65+
self, frament: Fragment, *args, model_path: Path, output_folder: Path = DEFAULT_OUTPUT_FOLDER, **kwargs
66+
):
6467
self.logger = logging.getLogger("{}.{}".format(__name__, type(self).__name__))
6568
self._input_dataset_key = "image"
6669
self._pred_dataset_key = "pred"
6770

6871
self.model_path = model_path
69-
self.output_folder = output_folder if output_folder else LiverTumorSegOperator.DEFAULT_OUTPUT_FOLDER
72+
self.output_folder = output_folder
7073
self.output_folder.mkdir(parents=True, exist_ok=True)
7174
self.fragement = frament # Cache and later pass the Fragment/Application to contained operator(s)
7275
self.input_name_image = "image"

monai/deploy/operators/dicom_seg_writer_operator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def to_segment_description(self, segment_number: int) -> hd.seg.SegmentDescripti
154154
)
155155

156156

157-
# @md.env(pip_packages=["pydicom >= 2.3.0", "highdicom >= 0.18.2"])
157+
# @md.env(pip_packages=["pydicom >= 2.3.0", "highdicom >= 0.18.2, "SimpleITK>=2.0.0"])
158158
class DICOMSegmentationWriterOperator(Operator):
159159
"""
160160
This operator writes out a DICOM Segmentation Part 10 file to disk
@@ -279,7 +279,7 @@ def process_images(
279279
):
280280
""" """
281281
# Get the seg image in numpy, and if the image is passed in as object, need to fake a input path.
282-
seg_image_numpy = image
282+
seg_image_numpy: np.ndarray = None
283283

284284
if isinstance(image, Image):
285285
seg_image_numpy = image.asnumpy()

monai/deploy/operators/monai_bundle_inference_operator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,13 +670,13 @@ def _receive_input(self, name: str, op_input, context):
670670
if not value.exists():
671671
raise ValueError(f"Input path, {value}, does not exist.")
672672

673-
file_path = value.path / name
673+
file_path = value / name
674674
# The named input can only be a folder as of now, but just in case things change.
675675
if value.is_file():
676676
file_path = value
677677
elif not file_path.exists() and value.is_dir():
678678
# Expect one and only one file exists for use.
679-
files = [f for f in value.path.glob("*") if f.is_file()]
679+
files = [f for f in value.glob("*") if f.is_file()]
680680
if len(files) != 1:
681681
raise ValueError(f"Input path, {value}, should have one and only one file.")
682682

0 commit comments

Comments
 (0)