New is_runpod() function (#18761)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2025-01-19 17:19:57 +01:00 committed by GitHub
parent 87fd0b1b30
commit 42a220c71d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -87,6 +87,10 @@ keywords: Ultralytics, utils, TQDM, Python, ML, Machine Learning utilities, YOLO
<br><br><hr><br> <br><br><hr><br>
## ::: ultralytics.utils.is_runpod
<br><br><hr><br>
## ::: ultralytics.utils.is_docker ## ::: ultralytics.utils.is_docker
<br><br><hr><br> <br><br><hr><br>

View file

@ -577,6 +577,16 @@ def is_jupyter():
return IS_COLAB or IS_KAGGLE return IS_COLAB or IS_KAGGLE
def is_runpod():
"""
Check if the current script is running inside a RunPod container.
Returns:
(bool): True if running in RunPod, False otherwise.
"""
return "RUNPOD_POD_ID" in os.environ
def is_docker() -> bool: def is_docker() -> bool:
""" """
Determine if the script is running inside a Docker container. Determine if the script is running inside a Docker container.
@ -1042,7 +1052,7 @@ def set_sentry():
auto_enabling_integrations=False, auto_enabling_integrations=False,
traces_sample_rate=1.0, traces_sample_rate=1.0,
release=__version__, release=__version__,
environment="production", # 'dev' or 'production' environment="runpod" if is_runpod() else "production",
before_send=before_send, before_send=before_send,
ignore_errors=[KeyboardInterrupt, FileNotFoundError], ignore_errors=[KeyboardInterrupt, FileNotFoundError],
) )