@@ -174,7 +174,7 @@ def _get_git_release_url(repo_owner: str, repo_name: str, tag_name: str, filenam
174174
175175
176176def _get_ngc_bundle_url (model_name : str , version : str ) -> str :
177- return f"{ NGC_BASE_URL } /{ model_name .lower ()} /versions/{ version } /zip "
177+ return f"{ NGC_BASE_URL } /{ model_name .lower ()} /versions/{ version } /files "
178178
179179
180180def _get_ngc_private_base_url (repo : str ) -> str :
@@ -218,6 +218,21 @@ def _remove_ngc_prefix(name: str, prefix: str = "monai_") -> str:
218218 return name
219219
220220
221+ def _get_all_download_files (request_url , headers = None ) -> list [str ]:
222+ if not has_requests :
223+ raise ValueError ("requests package is required, please install it." )
224+ headers = {} if headers is None else headers
225+ response = requests_get (request_url , headers = headers )
226+ response .raise_for_status ()
227+ model_info = json .loads (response .text )
228+
229+ if not isinstance (model_info , dict ) or "modelFiles" not in model_info :
230+ raise ValueError ("The data is not a dictionary or it does not have the key 'modelFiles'." )
231+
232+ model_files = model_info ["modelFiles" ]
233+ return [f ["path" ] for f in model_files ]
234+
235+
221236def _download_from_ngc (
222237 download_path : Path ,
223238 filename : str ,
@@ -229,12 +244,12 @@ def _download_from_ngc(
229244 # ensure prefix is contained
230245 filename = _add_ngc_prefix (filename , prefix = prefix )
231246 url = _get_ngc_bundle_url (model_name = filename , version = version )
232- filepath = download_path / f"{ filename } _v{ version } .zip"
233247 if remove_prefix :
234248 filename = _remove_ngc_prefix (filename , prefix = remove_prefix )
235- extract_path = download_path / f"{ filename } "
236- download_url (url = url , filepath = filepath , hash_val = None , progress = progress )
237- extractall (filepath = filepath , output_dir = extract_path , has_base = True )
249+ filepath = download_path / filename
250+ filepath .mkdir (parents = True , exist_ok = True )
251+ for file in _get_all_download_files (url ):
252+ download_url (url = f"{ url } /{ file } " , filepath = f"{ filepath } /{ file } " , hash_val = None , progress = progress )
238253
239254
240255def _download_from_ngc_private (
0 commit comments