From 80c59e24614f5ffd759ed5be404d263cdf77e772 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 1 Apr 2024 13:31:30 +0200 Subject: [PATCH] Retry `check_requirements` once on failure (#9466) --- ultralytics/utils/checks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ultralytics/utils/checks.py b/ultralytics/utils/checks.py index 8d3a69b3..fbd00f76 100644 --- a/ultralytics/utils/checks.py +++ b/ultralytics/utils/checks.py @@ -28,6 +28,7 @@ from ultralytics.utils import ( ONLINE, ROOT, USER_CONFIG_DIR, + Retry, SimpleNamespace, ThreadingLocked, TryExcept, @@ -390,7 +391,8 @@ def check_requirements(requirements=ROOT.parent / "requirements.txt", exclude=() try: t = time.time() assert is_online(), "AutoUpdate skipped (offline)" - LOGGER.info(subprocess.check_output(f"pip install --no-cache {s} {cmds}", shell=True).decode()) + with Retry(times=1, delay=1): # retry once on failure after 1 second + LOGGER.info(subprocess.check_output(f"pip install --no-cache {s} {cmds}", shell=True).decode()) dt = time.time() - t LOGGER.info( f"{prefix} AutoUpdate success ✅ {dt:.1f}s, installed {n} package{'s' * (n > 1)}: {pkgs}\n"