MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _get_latest_bundle_version_ngc

Function _get_latest_bundle_version_ngc

monai/bundle/scripts.py:376–404  ·  view source on GitHub ↗
(name: str, repo: str | None = None, headers: dict | None = None)

Source from the content-addressed store, hash-verified

374
375
376def _get_latest_bundle_version_ngc(name: str, repo: str | None = None, headers: dict | None = None) -> str:
377 base_url = _get_ngc_private_base_url(repo) if repo else NGC_BASE_URL
378 version_endpoint = base_url + f"/{name.lower()}/versions/"
379
380 if not has_requests:
381 raise ValueError("requests package is required, please install it.")
382
383 version_header = {"Accept-Encoding": "gzip, deflate"} # Excluding 'zstd' to fit NGC requirements
384 if headers:
385 version_header.update(headers)
386 resp = requests.get(version_endpoint, headers=version_header)
387 resp.raise_for_status()
388 model_info = json.loads(resp.text)
389 latest_versions = _list_latest_versions(model_info)
390
391 for version in latest_versions:
392 file_endpoint = base_url + f"/{name.lower()}/versions/{version}/files/configs/metadata.json"
393 resp = requests.get(file_endpoint, headers=headers)
394 metadata = json.loads(resp.text)
395 resp.raise_for_status()
396 # if the package version is not available or the model is compatible with the package version
397 is_compatible, _ = _examine_monai_version(metadata["monai_version"])
398 if is_compatible:
399 if version != latest_versions[0]:
400 logger.info(f"Latest version is {latest_versions[0]}, but the compatible version is {version}.")
401 return version
402
403 # if no compatible version is found, return the latest version
404 return latest_versions[0]
405
406
407def _get_latest_bundle_version(

Callers 1

Calls 6

_list_latest_versionsFunction · 0.85
_examine_monai_versionFunction · 0.85
getMethod · 0.80
infoMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…