Skip to content

Commit 339292c

Browse files
authored
Fix error in download bundle from ngc (#6963)
Fixes #6962. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] 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: KumoLiu <yunl@nvidia.com>
1 parent 8040aa2 commit 339292c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

monai/bundle/scripts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ def _get_git_release_url(repo_owner: str, repo_name: str, tag_name: str, filenam
155155

156156

157157
def _get_ngc_bundle_url(model_name: str, version: str) -> str:
158-
return f"https://api.ngc.nvidia.com/v2/models/nvidia/monaitoolkit/{model_name}/versions/{version}/zip"
158+
return f"https://api.ngc.nvidia.com/v2/models/nvidia/monaitoolkit/{model_name.lower()}/versions/{version}/zip"
159159

160160

161161
def _get_monaihosting_bundle_url(model_name: str, version: str) -> str:
162162
monaihosting_root_path = "https://api.ngc.nvidia.com/v2/models/nvidia/monaihosting"
163-
return f"{monaihosting_root_path}/{model_name}/versions/{version}/files/{model_name}_v{version}.zip"
163+
return f"{monaihosting_root_path}/{model_name}/versions/{version}/files/{model_name.lower()}_v{version}.zip"
164164

165165

166166
def _download_from_github(repo: str, download_path: Path, filename: str, progress: bool = True) -> None:

tests/test_bundle_download.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272
]
7373

7474
TEST_CASE_8 = [
75+
"Spleen_CT_Segmentation",
76+
"cuda" if torch.cuda.is_available() else "cpu",
77+
{"spatial_dims": 3, "out_channels": 5},
78+
]
79+
80+
TEST_CASE_9 = [
7581
["network.json", "test_output.pt", "test_input.pt", "large_files.yaml"],
7682
"test_bundle",
7783
"https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/test_bundle_v0.1.2.zip",
@@ -204,7 +210,7 @@ def test_load_weights(self, bundle_files, bundle_name, repo, device, model_file)
204210
output_3 = model_3.forward(input_tensor)
205211
assert_allclose(output_3, expected_output, atol=1e-4, rtol=1e-4, type_test=False)
206212

207-
@parameterized.expand([TEST_CASE_7])
213+
@parameterized.expand([TEST_CASE_7, TEST_CASE_8])
208214
@skip_if_quick
209215
def test_load_weights_with_net_override(self, bundle_name, device, net_override):
210216
with skip_if_downloading_fails():
@@ -282,7 +288,7 @@ def test_load_ts_module(self, bundle_files, bundle_name, version, repo, device,
282288

283289

284290
class TestDownloadLargefiles(unittest.TestCase):
285-
@parameterized.expand([TEST_CASE_8])
291+
@parameterized.expand([TEST_CASE_9])
286292
@skip_if_quick
287293
def test_url_download_large_files(self, bundle_files, bundle_name, url, hash_val):
288294
with skip_if_downloading_fails():

0 commit comments

Comments
 (0)