From 42a220c71d03084a1ba2b3b0ee596314c96979e0 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 19 Jan 2025 17:19:57 +0100 Subject: [PATCH] New `is_runpod()` function (#18761) Signed-off-by: Glenn Jocher Co-authored-by: UltralyticsAssistant --- docs/en/reference/utils/__init__.md | 4 ++++ ultralytics/utils/__init__.py | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/en/reference/utils/__init__.md b/docs/en/reference/utils/__init__.md index 9b7d1b58..981adc6c 100644 --- a/docs/en/reference/utils/__init__.md +++ b/docs/en/reference/utils/__init__.md @@ -87,6 +87,10 @@ keywords: Ultralytics, utils, TQDM, Python, ML, Machine Learning utilities, YOLO



+## ::: ultralytics.utils.is_runpod + +



+ ## ::: ultralytics.utils.is_docker



diff --git a/ultralytics/utils/__init__.py b/ultralytics/utils/__init__.py index 104c1231..fa303923 100644 --- a/ultralytics/utils/__init__.py +++ b/ultralytics/utils/__init__.py @@ -577,6 +577,16 @@ def is_jupyter(): 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: """ Determine if the script is running inside a Docker container. @@ -1042,7 +1052,7 @@ def set_sentry(): auto_enabling_integrations=False, traces_sample_rate=1.0, release=__version__, - environment="production", # 'dev' or 'production' + environment="runpod" if is_runpod() else "production", before_send=before_send, ignore_errors=[KeyboardInterrupt, FileNotFoundError], )