Skip to content

add ngc download bundle#5710

Merged
wyli merged 14 commits intoProject-MONAI:devfrom
yiheng-wang-nv:5679-add-ngc-source-in-bundle-download
Dec 17, 2022
Merged

add ngc download bundle#5710
wyli merged 14 commits intoProject-MONAI:devfrom
yiheng-wang-nv:5679-add-ngc-source-in-bundle-download

Conversation

@yiheng-wang-nv
Copy link
Copy Markdown
Contributor

@yiheng-wang-nv yiheng-wang-nv commented Dec 12, 2022

Signed-off-by: Yiheng Wang [email protected]

Fixes #5679 and #5320

Description

This PR adds the support of download bundles from ngc: https://catalog.ngc.nvidia.com/models?filters=&orderBy=scoreDESC&query=monai
In addition, when "version" is not provided, it changes to download the latest version in default.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • 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.

Signed-off-by: Yiheng Wang <[email protected]>
@Nic-Ma Nic-Ma requested a review from wyli December 12, 2022 15:19
@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Dec 15, 2022

@yiheng-wang-nv yiheng-wang-nv marked this pull request as ready for review December 16, 2022 08:00
Signed-off-by: Yiheng Wang <[email protected]>
Signed-off-by: Yiheng Wang <[email protected]>
Signed-off-by: Yiheng Wang <[email protected]>
@mingxin-zheng
Copy link
Copy Markdown
Contributor

mingxin-zheng commented Dec 16, 2022

The latest version cannot be resolved in NGC source with spleen_ct_segmentation as the name instead of monai_spleen_ct_segmentation

BUNDLE_DOWNLOAD_SRC=ngc python -m monai.bundle download --name spleen_ct_segmentation
2022-12-16 10:13:47,797 - INFO - --- input summary of monai.bundle.scripts.download ---
2022-12-16 10:13:47,797 - INFO - > name: 'spleen_ct_segmentation'
2022-12-16 10:13:47,797 - INFO - > source: 'ngc'
2022-12-16 10:13:47,797 - INFO - > progress: True
2022-12-16 10:13:47,797 - INFO - ---


spleen_ct_segmentation
monai_spleen_ct_segmentation
monai_spleen_ct_segmentation_vNone.zip: 0.00B [00:00, ?B/s]
2022-12-16 10:13:51,118 - ERROR - Download failed from https://api.ngc.nvidia.com/v2/models/nvidia/monaitoolkit/monai_spleen_ct_segmentation/versions/None/zip to /tmp/tmpqfrv7010/monai_spleen_ct_segmentation_vNone.zip.
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/conda/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/workspace/monai/monai-in-dev/monai/bundle/__main__.py", line 18, in <module>
    fire.Fire()
  File "/opt/conda/lib/python3.8/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/opt/conda/lib/python3.8/site-packages/fire/core.py", line 466, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/opt/conda/lib/python3.8/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/workspace/monai/monai-in-dev/monai/bundle/scripts.py", line 291, in download
    _download_from_ngc(
  File "/workspace/monai/monai-in-dev/monai/bundle/scripts.py", line 151, in _download_from_ngc
    download_url(url=url, filepath=filepath, hash_val=None, progress=progress)
  File "/workspace/monai/monai-in-dev/monai/apps/utils.py", line 203, in download_url
    _download_with_progress(url, tmp_name, progress=progress)
  File "/workspace/monai/monai-in-dev/monai/apps/utils.py", line 114, in _download_with_progress
    raise e
  File "/workspace/monai/monai-in-dev/monai/apps/utils.py", line 107, in _download_with_progress
    urlretrieve(url, filepath, reporthook=t.update_to)
  File "/opt/conda/lib/python3.8/urllib/request.py", line 247, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/opt/conda/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/opt/conda/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/opt/conda/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/opt/conda/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/opt/conda/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/opt/conda/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: 

@yiheng-wang-nv
Copy link
Copy Markdown
Contributor Author

…iheng-wang-nv/MONAI into 5679-add-ngc-source-in-bundle-download
Signed-off-by: Yiheng Wang <[email protected]>
Signed-off-by: Yiheng Wang <[email protected]>
Copy link
Copy Markdown
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

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

looks good to me, @Nic-Ma could you please help confirm..

@mingxin-zheng
Copy link
Copy Markdown
Contributor

mingxin-zheng commented Dec 17, 2022

The behavior looks good to me now

> BUNDLE_DOWNLOAD_SRC=ngc python -m monai.bundle download --name spleen_ct_segmentation --bundle_dir ./abc
2022-12-17 12:27:41,263 - INFO - --- input summary of monai.bundle.scripts.download ---
2022-12-17 12:27:41,263 - INFO - > name: 'spleen_ct_segmentation'
2022-12-17 12:27:41,263 - INFO - > bundle_dir: './abc'
2022-12-17 12:27:41,263 - INFO - > source: 'ngc'
2022-12-17 12:27:41,263 - INFO - > remove_prefix: 'monai_'
2022-12-17 12:27:41,263 - INFO - > progress: True
2022-12-17 12:27:41,263 - INFO - ---


monai_spleen_ct_segmentation_v0.3.7.zip: 34.0MB [00:19, 1.83MB/s]                                                                                                                                          
2022-12-17 12:28:03,310 - INFO - Downloaded: abc/monai_spleen_ct_segmentation_v0.3.7.zip
2022-12-17 12:28:03,310 - INFO - Expected md5 is None, skip md5 check for file abc/monai_spleen_ct_segmentation_v0.3.7.zip.
2022-12-17 12:28:03,310 - INFO - Writing into directory: abc/spleen_ct_segmentation.

> ls abc/
monai_spleen_ct_segmentation_v0.3.7.zip  spleen_ct_segmentation

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Dec 17, 2022

/build

@wyli wyli merged commit 67d84d3 into Project-MONAI:dev Dec 17, 2022
@yiheng-wang-nv yiheng-wang-nv deleted the 5679-add-ngc-source-in-bundle-download branch December 19, 2022 02:31
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.

Add NVIDIA NGC source support to the bundle.download

4 participants