@@ -541,11 +541,16 @@ def load(
541541 return model
542542
543543
544+ @deprecated_arg_default ("tag" , "hosting_storage_v1" , "dev" , since = "1.2" , replaced = "1.5" )
544545def _get_all_bundles_info (
545546 repo : str = "Project-MONAI/model-zoo" , tag : str = "hosting_storage_v1" , auth_token : str | None = None
546547) -> dict [str , dict [str , dict [str , Any ]]]:
547548 if has_requests :
548- request_url = f"https://api.github.com/repos/{ repo } /releases"
549+ if tag == "hosting_storage_v1" :
550+ request_url = f"https://api.github.com/repos/{ repo } /releases"
551+ else :
552+ request_url = f"https://raw.githubusercontent.com/{ repo } /{ tag } /models/model_info.json"
553+
549554 if auth_token is not None :
550555 headers = {"Authorization" : f"Bearer { auth_token } " }
551556 resp = requests_get (request_url , headers = headers )
@@ -558,33 +563,39 @@ def _get_all_bundles_info(
558563 bundle_name_pattern = re .compile (r"_v\d*." )
559564 bundles_info : dict [str , dict [str , dict [str , Any ]]] = {}
560565
561- for release in releases_list :
562- if release ["tag_name" ] == tag :
563- for asset in release ["assets" ]:
564- asset_name = bundle_name_pattern .split (asset ["name" ])[0 ]
565- if asset_name not in bundles_info :
566- bundles_info [asset_name ] = {}
567- asset_version = asset ["name" ].split (f"{ asset_name } _v" )[- 1 ].replace (".zip" , "" )
568- bundles_info [asset_name ][asset_version ] = {
569- "id" : asset ["id" ],
570- "name" : asset ["name" ],
571- "size" : asset ["size" ],
572- "download_count" : asset ["download_count" ],
573- "browser_download_url" : asset ["browser_download_url" ],
574- "created_at" : asset ["created_at" ],
575- "updated_at" : asset ["updated_at" ],
576- }
577- return bundles_info
566+ if tag == "hosting_storage_v1" :
567+ for release in releases_list :
568+ if release ["tag_name" ] == tag :
569+ for asset in release ["assets" ]:
570+ asset_name = bundle_name_pattern .split (asset ["name" ])[0 ]
571+ if asset_name not in bundles_info :
572+ bundles_info [asset_name ] = {}
573+ asset_version = asset ["name" ].split (f"{ asset_name } _v" )[- 1 ].replace (".zip" , "" )
574+ bundles_info [asset_name ][asset_version ] = dict (asset )
575+ return bundles_info
576+ else :
577+ for asset in releases_list .keys ():
578+ asset_name = bundle_name_pattern .split (asset )[0 ]
579+ if asset_name not in bundles_info :
580+ bundles_info [asset_name ] = {}
581+ asset_version = asset .split (f"{ asset_name } _v" )[- 1 ]
582+ bundles_info [asset_name ][asset_version ] = {
583+ "name" : asset ,
584+ "browser_download_url" : releases_list [asset ]["source" ],
585+ }
578586 return bundles_info
579587
580588
589+ @deprecated_arg_default ("tag" , "hosting_storage_v1" , "dev" , since = "1.3" , replaced = "1.5" )
581590def get_all_bundles_list (
582591 repo : str = "Project-MONAI/model-zoo" , tag : str = "hosting_storage_v1" , auth_token : str | None = None
583592) -> list [tuple [str , str ]]:
584593 """
585594 Get all bundles names (and the latest versions) that are stored in the release of specified repository
586- with the provided tag. The default values of arguments correspond to the release of MONAI model zoo.
587- In order to increase the rate limits of calling Github APIs, you can input your personal access token.
595+ with the provided tag. If tag is "dev", will get model information from
596+ https://raw.githubusercontent.com/repo_owner/repo_name/dev/models/model_info.json.
597+ The default values of arguments correspond to the release of MONAI model zoo. In order to increase the
598+ rate limits of calling Github APIs, you can input your personal access token.
588599 Please check the following link for more details about rate limiting:
589600 https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting
590601
@@ -610,6 +621,7 @@ def get_all_bundles_list(
610621 return bundles_list
611622
612623
624+ @deprecated_arg_default ("tag" , "hosting_storage_v1" , "dev" , since = "1.3" , replaced = "1.5" )
613625def get_bundle_versions (
614626 bundle_name : str ,
615627 repo : str = "Project-MONAI/model-zoo" ,
@@ -618,7 +630,8 @@ def get_bundle_versions(
618630) -> dict [str , list [str ] | str ]:
619631 """
620632 Get the latest version, as well as all existing versions of a bundle that is stored in the release of specified
621- repository with the provided tag.
633+ repository with the provided tag. If tag is "dev", will get model information from
634+ https://raw.githubusercontent.com/repo_owner/repo_name/dev/models/model_info.json.
622635 In order to increase the rate limits of calling Github APIs, you can input your personal access token.
623636 Please check the following link for more details about rate limiting:
624637 https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting
@@ -646,6 +659,7 @@ def get_bundle_versions(
646659 return {"latest_version" : all_versions [- 1 ], "all_versions" : all_versions }
647660
648661
662+ @deprecated_arg_default ("tag" , "hosting_storage_v1" , "dev" , since = "1.3" , replaced = "1.5" )
649663def get_bundle_info (
650664 bundle_name : str ,
651665 version : str | None = None ,
@@ -656,7 +670,9 @@ def get_bundle_info(
656670 """
657671 Get all information
658672 (include "id", "name", "size", "download_count", "browser_download_url", "created_at", "updated_at") of a bundle
659- with the specified bundle name and version.
673+ with the specified bundle name and version which is stored in the release of specified repository with the provided tag.
674+ Since v1.5, "hosting_storage_v1" will be deprecated in favor of 'dev', which contains only "name" and "browser_download_url".
675+ information about a bundle.
660676 In order to increase the rate limits of calling Github APIs, you can input your personal access token.
661677 Please check the following link for more details about rate limiting:
662678 https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting
@@ -685,7 +701,7 @@ def get_bundle_info(
685701 if version not in bundle_info :
686702 raise ValueError (f"version: { version } of bundle: { bundle_name } is not existing." )
687703
688- return bundle_info [version ]
704+ return bundle_info [version ] # type: ignore[no-any-return]
689705
690706
691707@deprecated_arg ("runner_id" , since = "1.1" , removed = "1.3" , new_name = "run_id" , msg_suffix = "please use `run_id` instead." )
0 commit comments