Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.73k stars 1.05k forks source link

integration error monai/metrics/cumulative_average.py #5444

Closed wyli closed 1 year ago

wyli commented 1 year ago
12:47:57  Traceback (most recent call last):
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/utils/module.py", line 199, in load_submodules
12:47:57      mod = import_module(name)
12:47:57    File "/opt/conda/lib/python3.8/importlib/__init__.py", line 127, in import_module
12:47:57      return _bootstrap._gcd_import(name[level:], package, level)
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/apps/pathology/__init__.py", line 15, in <module>
12:47:57      from .metrics import LesionFROC
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/apps/pathology/metrics/__init__.py", line 12, in <module>
12:47:57      from .lesion_froc import LesionFROC
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/apps/pathology/metrics/lesion_froc.py", line 18, in <module>
12:47:57      from monai.metrics import compute_fp_tp_probs, compute_froc_curve_data, compute_froc_score
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/metrics/__init__.py", line 14, in <module>
12:47:57      from .cumulative_average import CumulativeAverage
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/metrics/cumulative_average.py", line 17, in <module>
12:47:57      from numpy.typing import NDArray
12:47:57  ImportError: cannot import name 'NDArray' from 'numpy.typing' (/opt/conda/lib/python3.8/site-packages/numpy/typing/__init__.py)
12:47:57  
12:47:57  The above exception was the direct cause of the following exception:
12:47:57  
12:47:57  Traceback (most recent call last):
12:47:57    File "/opt/conda/lib/python3.8/runpy.py", line 194, in _run_module_as_main
12:47:57      return _run_code(code, main_globals, None,
12:47:57    File "/opt/conda/lib/python3.8/runpy.py", line 87, in _run_code
12:47:57      exec(code, run_globals)
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/tests/utils.py", line 38, in <module>
12:47:57      from monai.apps.utils import download_url
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/__init__.py", line 55, in <module>
12:47:57      load_submodules(sys.modules[__name__], False, exclude_pattern=excludes)
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/utils/module.py", line 209, in load_submodules
12:47:57      raise type(e)(f"{e}\n{msg}").with_traceback(e.__traceback__) from e  # raise with modified message
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/utils/module.py", line 199, in load_submodules
12:47:57      mod = import_module(name)
12:47:57    File "/opt/conda/lib/python3.8/importlib/__init__.py", line 127, in import_module
12:47:57      return _bootstrap._gcd_import(name[level:], package, level)
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/apps/pathology/__init__.py", line 15, in <module>
12:47:57      from .metrics import LesionFROC
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/apps/pathology/metrics/__init__.py", line 12, in <module>
12:47:57      from .lesion_froc import LesionFROC
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/apps/pathology/metrics/lesion_froc.py", line 18, in <module>
12:47:57      from monai.metrics import compute_fp_tp_probs, compute_froc_curve_data, compute_froc_score
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/metrics/__init__.py", line 14, in <module>
12:47:57      from .cumulative_average import CumulativeAverage
12:47:57    File "/home/jenkins/agent/workspace/MONAI-postmerge/monai_github/monai/metrics/cumulative_average.py", line 17, in <module>
12:47:57      from numpy.typing import NDArray
12:47:57  ImportError: cannot import name 'NDArray' from 'numpy.typing' (/opt/conda/lib/python3.8/site-packages/numpy/typing/__init__.py)
wyli commented 1 year ago

I include a patch here 007f93ecb64252bae351f6b54ce940e714c8b8fe in https://github.com/Project-MONAI/MONAI/pull/5438

myron commented 1 year ago

Thank you. It seems from numpy.typing import NDArray might be only in the newer numpy versions https://numpy.org/devdocs/reference/typing.html#numpy.typing.NDArray, which is already in nvidia/pytorch containers