@@ -528,7 +528,9 @@ def download(
528528 If source is "ngc_private", you need specify the NGC_API_KEY in the environment variable.
529529 repo: repo name. This argument is used when `url` is `None` and `source` is "github" or "huggingface_hub".
530530 If `source` is "github", it should be in the form of "repo_owner/repo_name/release_tag".
531- If `source` is "huggingface_hub", it should be in the form of "repo_owner/repo_name".
531+ If `source` is "huggingface_hub", it should be in the form of "repo_owner/repo_name". Please note that
532+ bundles for "monaihosting" source are also hosted on Hugging Face Hub, but the "repo_id" is always in the form
533+ of "MONAI/bundle_name", therefore, this argument is not required for "monaihosting" source.
532534 If `source` is "ngc_private", it should be in the form of "org/org_name" or "org/org_name/team/team_name",
533535 or you can specify the environment variable NGC_ORG and NGC_TEAM.
534536 url: url to download the data. If not `None`, data will be downloaded directly
@@ -600,11 +602,15 @@ def download(
600602 _download_from_github (repo = repo_ , download_path = bundle_dir_ , filename = name_ver , progress = progress_ )
601603 elif source_ == "monaihosting" :
602604 try :
605+ extract_path = os .path .join (bundle_dir_ , name_ )
606+ huggingface_hub .snapshot_download (repo_id = f"MONAI/{ name_ } " , revision = version_ , local_dir = extract_path )
607+ except (huggingface_hub .errors .RevisionNotFoundError , huggingface_hub .errors .RepositoryNotFoundError ):
608+ # if bundle or version not found from huggingface, download from ngc monaihosting
603609 _download_from_monaihosting (
604610 download_path = bundle_dir_ , filename = name_ , version = version_ , progress = progress_
605611 )
606612 except urllib .error .HTTPError :
607- # for monaihosting bundles, if cannot download from default host , download according to bundle_info
613+ # if also cannot download from ngc monaihosting , download according to bundle_info
608614 _download_from_bundle_info (
609615 download_path = bundle_dir_ , filename = name_ , version = version_ , progress = progress_
610616 )
0 commit comments