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

Function _get_ngc_token

monai/bundle/scripts.py:294–308  ·  view source on GitHub ↗

Try to connect to NGC.

(api_key, retry=0)

Source from the content-addressed store, hash-verified

292
293
294def _get_ngc_token(api_key, retry=0):
295 """Try to connect to NGC."""
296 url = "https://authn.nvidia.com/token?service=ngc"
297 headers = {"Accept": "application/json", "Authorization": "ApiKey " + api_key}
298 if has_requests:
299 response = requests.get(url, headers=headers)
300 if not response.ok:
301 # retry 3 times, if failed, raise an error.
302 if retry < 3:
303 logger.info(f"Retrying {retry} time(s) to GET {url}.")
304 return _get_ngc_token(url, retry + 1)
305 raise RuntimeError("NGC API response is not ok. Failed to get token.")
306 else:
307 token = response.json()["token"]
308 return token
309
310
311def _examine_monai_version(monai_version: str) -> tuple[bool, str]:

Callers 1

downloadFunction · 0.85

Calls 2

getMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…