Retry check_requirements once on failure (#9466)

This commit is contained in:
Glenn Jocher 2024-04-01 13:31:30 +02:00 committed by GitHub
parent 5268ca14eb
commit 80c59e2461
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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"