Project-MONAI/monai-deploy-app-sdk

[Enhancement] Use of the missing attribute on the DicomInstance class

MMelQin opened this issue · 1 comments

Describe the bug
New version of pytype has found a new error, see below. Since this particular operator will still be used in the new versions of the App SDK, the flagged error needs to be investigated. Also note, there is currently no runtime error.

File "/home/mqin/src/monai-deploy-app-sdk/monai/deploy/operators/dicom_series_to_volume_operator.py", line 229, in prepare_series: No attribute 'first_pixel_on_slice_normal' on monai.deploy.core.domain.dicom_sop_instance.DICOMSOPInstance [attribute-error]

Steps/Code to reproduce bug

  • Inspect the said file, and try to find the attribute, or
  • In the pytype settings, make sure in the disable dose not contains 'attribute-error', and then run pytype on monai/deploy

Expected behavior
There should not be attribute-error and this particular error should not be disableed in the pytype settings.

Environment details (please complete the following information)

  • OS/Platform: Linux
  • Python Version: 3.7/3.8
  • Method of MONAI Deploy App SDK install: [from source]
  • SDK Version: 0.5/main

Additional context
This error is currently disabled in pytype report, so that the pull request build can succeed. Creating this bug is to schedule a real fix.

The attributes, distance and first_pixel_on_slice_normal are added to an instantiated DICOMInstance object, as they are calculated for specific DICOMSeries instance, see here and here, before referenced in the subsequent code block. So, it correctly uses the python language feature but the pytype somehow did not infer it correctly and raised false positive error.

The code for correct, but disabling attribute-error reporting from pytype is not a good idea. Will consider in the next release/migration to add the attributes to the init function, and in the meantime disable attribute-error reporting when checking code before PR and build.