Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks for monai bundles after download and warn if incompatible #7938

Merged
merged 17 commits into from
Jul 24, 2024
Merged

Add checks for monai bundles after download and warn if incompatible #7938

merged 17 commits into from
Jul 24, 2024

Conversation

mingxin-zheng
Copy link
Contributor

@mingxin-zheng mingxin-zheng commented Jul 22, 2024

Fixes #7930 .

Description

Check the monai version in metadata JSON and warn if the version is newer than the package being used.

Demonstration

Warning when the version is hardcoded to 1.2 from monaihosting

root@MS-7D31:/workspace/MONAI# python -m monai.bundle download spleen_ct_segmentation
2024-07-23 11:00:31,286 - INFO - --- input summary of monai.bundle.scripts.download ---
2024-07-23 11:00:31,286 - INFO - > name: 'spleen_ct_segmentation'
2024-07-23 11:00:31,286 - INFO - > source: 'monaihosting'
2024-07-23 11:00:31,286 - INFO - > remove_prefix: 'monai_'
2024-07-23 11:00:31,286 - INFO - > progress: True
2024-07-23 11:00:31,286 - INFO - ---


2024-07-23 11:00:31,985 - INFO - Expected md5 is None, skip md5 check for file /root/.cache/torch/hub/bundle/spleen_ct_segmentation_v0.5.8.zip.
2024-07-23 11:00:31,986 - INFO - File exists: /root/.cache/torch/hub/bundle/spleen_ct_segmentation_v0.5.8.zip, skipped downloading.
2024-07-23 11:00:31,986 - INFO - Writing into directory: /root/.cache/torch/hub/bundle.
2024-07-23 11:00:32,176 - WARNING - Your MONAI version is 1.2, but the bundle is built on MONAI version 1.3.2.

Auto select version if the download src is from NGC

root@MS-7D31:/workspace/MONAI# BUNDLE_DOWNLOAD_SRC=ngc python -m monai.bundle download spleen_ct_segmentation
2024-07-23 11:02:12,277 - INFO - --- input summary of monai.bundle.scripts.download ---
2024-07-23 11:02:12,277 - INFO - > name: 'spleen_ct_segmentation'
2024-07-23 11:02:12,277 - INFO - > source: 'ngc'
2024-07-23 11:02:12,277 - INFO - > remove_prefix: 'monai_'
2024-07-23 11:02:12,277 - INFO - > progress: True
2024-07-23 11:02:12,277 - INFO - ---


monai_spleen_ct_segmentation_v0.3.7.zip: 34.0MB [00:01, 24.1MB/s]                                                                                                                                                       
2024-07-23 11:02:17,953 - INFO - Downloaded: /root/.cache/torch/hub/bundle/monai_spleen_ct_segmentation_v0.3.7.zip
2024-07-23 11:02:17,954 - INFO - Expected md5 is None, skip md5 check for file /root/.cache/torch/hub/bundle/monai_spleen_ct_segmentation_v0.3.7.zip.
2024-07-23 11:02:17,954 - INFO - Writing into directory: /root/.cache/torch/hub/bundle/spleen_ct_segmentation.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

mingxin-zheng and others added 11 commits July 22, 2024 17:18
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
@mingxin-zheng mingxin-zheng changed the title WIP: Add checks for monai bundles after download and warn if incompatible Add checks for monai bundles after download and warn if incompatible Jul 23, 2024
monai/bundle/scripts.py Outdated Show resolved Hide resolved
monai/bundle/scripts.py Outdated Show resolved Hide resolved
monai/bundle/scripts.py Outdated Show resolved Hide resolved
monai/bundle/scripts.py Show resolved Hide resolved
tests/test_bundle_download.py Show resolved Hide resolved
tests/test_bundle_download.py Show resolved Hide resolved
mingxin-zheng and others added 3 commits July 24, 2024 10:31
Co-authored-by: YunLiu <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
@KumoLiu
Copy link
Contributor

KumoLiu commented Jul 24, 2024

/build

@KumoLiu
Copy link
Contributor

KumoLiu commented Jul 24, 2024

Do you think we can add a logging information mentioned that the version we download is not the latest bundle version when we automatically select a version match the package version?

Copy link
Contributor

@KumoLiu KumoLiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one remaining comment, other parts looks good to me, thanks!

@mingxin-zheng
Copy link
Contributor Author

ation mentioned that the version we download is not the latest bundle version when we automatically select a version match the package version?

Sure let me change it then

@mingxin-zheng
Copy link
Contributor Author

Latest commit (1ce127d) should address the last comment. Thanks @KumoLiu :

Hardcode the version to 1.2 to trigger compatibility check, and download non-latest version.

2024-07-24 06:47:05,028 - INFO - --- input summary of monai.bundle.scripts.download ---
2024-07-24 06:47:05,028 - INFO - > name: 'spleen_ct_segmentation'
2024-07-24 06:47:05,028 - INFO - > source: 'ngc'
2024-07-24 06:47:05,028 - INFO - > remove_prefix: 'monai_'
2024-07-24 06:47:05,028 - INFO - > progress: True
2024-07-24 06:47:05,028 - INFO - ---


2024-07-24 06:47:08,814 - INFO - Latest version is 0.5.7, but the compatible version is 0.3.7.
monai_spleen_ct_segmentation_v0.3.7.zip: 34.0MB [00:03, 8.92MB/s]                                                                                                                                        
2024-07-24 06:47:12,810 - INFO - Downloaded: /root/.cache/torch/hub/bundle/monai_spleen_ct_segmentation_v0.3.7.zip
2024-07-24 06:47:12,810 - INFO - Expected md5 is None, skip md5 check for file /root/.cache/torch/hub/bundle/monai_spleen_ct_segmentation_v0.3.7.zip.
2024-07-24 06:47:12,810 - INFO - Writing into directory: /root/.cache/torch/hub/bundle/spleen_ct_segmentation.

Signed-off-by: Mingxin Zheng <[email protected]>
@KumoLiu
Copy link
Contributor

KumoLiu commented Jul 24, 2024

/build

@KumoLiu KumoLiu merged commit 316934a into Project-MONAI:dev Jul 24, 2024
28 checks passed
@mingxin-zheng mingxin-zheng deleted the mingxinz/autoselect-7930 branch July 25, 2024 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-select bundle version based on the version of MONAI
3 participants