diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 011f7cb5..25cc38ce 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -114,7 +114,7 @@ jobs: if: github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true' uses: nick-invision/retry@v3 with: - timeout_minutes: 60 + timeout_minutes: 120 retry_wait_seconds: 30 max_attempts: 2 # retry once command: | diff --git a/ultralytics/utils/checks.py b/ultralytics/utils/checks.py index e540b72a..9fe852a3 100644 --- a/ultralytics/utils/checks.py +++ b/ultralytics/utils/checks.py @@ -33,6 +33,7 @@ from ultralytics.utils import ( ROOT, TORCHVISION_VERSION, USER_CONFIG_DIR, + Retry, SimpleNamespace, ThreadingLocked, TryExcept, @@ -381,6 +382,11 @@ def check_requirements(requirements=ROOT.parent / "requirements.txt", exclude=() except (AssertionError, metadata.PackageNotFoundError): pkgs.append(r) + @Retry(times=2, delay=1) + def attempt_install(packages, commands): + """Attempt pip install command with retries on failure.""" + return subprocess.check_output(f"pip install --no-cache-dir {packages} {commands}", shell=True).decode() + s = " ".join(f'"{x}"' for x in pkgs) # console string if s: if install and AUTOINSTALL: # check environment variable @@ -389,7 +395,7 @@ def check_requirements(requirements=ROOT.parent / "requirements.txt", exclude=() try: t = time.time() assert ONLINE, "AutoUpdate skipped (offline)" - LOGGER.info(subprocess.check_output(f"pip install --no-cache-dir {s} {cmds}", shell=True).decode()) + LOGGER.info(attempt_install(s, cmds)) dt = time.time() - t LOGGER.info( f"{prefix} AutoUpdate success ✅ {dt:.1f}s, installed {n} package{'s' * (n > 1)}: {pkgs}\n"