mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-24 02:06:15 +00:00
Track native HTTP failed attempt timing
This commit is contained in:
@@ -620,6 +620,7 @@ def _print_range_timing_summary(fetch_pool: dict[str, float]) -> None:
|
|||||||
("range_body_s", "http body drain"),
|
("range_body_s", "http body drain"),
|
||||||
("range_chunk_gap_s", "http chunk wait"),
|
("range_chunk_gap_s", "http chunk wait"),
|
||||||
("range_join_s", "join response chunks"),
|
("range_join_s", "join response chunks"),
|
||||||
|
("range_failed_attempt_s", "http failed attempts"),
|
||||||
("range_retry_sleep_s", "http retry sleep"),
|
("range_retry_sleep_s", "http retry sleep"),
|
||||||
):
|
):
|
||||||
value = fetch_pool.get(key)
|
value = fetch_pool.get(key)
|
||||||
@@ -627,8 +628,18 @@ def _print_range_timing_summary(fetch_pool: dict[str, float]) -> None:
|
|||||||
print(f"| {label} | {value * 1000 / range_jobs:.3f} |")
|
print(f"| {label} | {value * 1000 / range_jobs:.3f} |")
|
||||||
if "range_retry_attempts" in fetch_pool:
|
if "range_retry_attempts" in fetch_pool:
|
||||||
print(f"| http retries | {fetch_pool['range_retry_attempts'] / range_jobs:.3f} |")
|
print(f"| http retries | {fetch_pool['range_retry_attempts'] / range_jobs:.3f} |")
|
||||||
|
if "range_exception_attempts" in fetch_pool:
|
||||||
|
print(f"| http exceptions | {fetch_pool['range_exception_attempts'] / range_jobs:.3f} |")
|
||||||
if fetch_pool.get("range_failed_requests"):
|
if fetch_pool.get("range_failed_requests"):
|
||||||
print(f"| http failed requests | {fetch_pool['range_failed_requests']:.0f} |")
|
print(f"| http failed requests | {fetch_pool['range_failed_requests']:.0f} |")
|
||||||
|
exception_counts = {
|
||||||
|
key.removeprefix("range_exception_"): value
|
||||||
|
for key, value in fetch_pool.items()
|
||||||
|
if key.startswith("range_exception_")
|
||||||
|
}
|
||||||
|
if exception_counts:
|
||||||
|
summary = ", ".join(f"{name}={count:.0f}" for name, count in sorted(exception_counts.items()))
|
||||||
|
print(f"| http exception counts | {summary} |")
|
||||||
status_counts = {
|
status_counts = {
|
||||||
key.removeprefix("range_status_"): value
|
key.removeprefix("range_status_"): value
|
||||||
for key, value in fetch_pool.items()
|
for key, value in fetch_pool.items()
|
||||||
|
|||||||
@@ -344,14 +344,25 @@ class NativeHTTPRangeFetcher:
|
|||||||
last_exc: Exception | None = None
|
last_exc: Exception | None = None
|
||||||
retry_attempts = 0.0
|
retry_attempts = 0.0
|
||||||
retry_sleep_s = 0.0
|
retry_sleep_s = 0.0
|
||||||
|
failed_attempt_s = 0.0
|
||||||
|
exception_attempts = 0.0
|
||||||
|
exception_counts: dict[str, float] = {}
|
||||||
for attempt in range(self.max_retries + 1):
|
for attempt in range(self.max_retries + 1):
|
||||||
|
attempt_start = time.perf_counter()
|
||||||
try:
|
try:
|
||||||
payload, status_code, timings = self._read_range_response_once(url, headers)
|
payload, status_code, timings = self._read_range_response_once(url, headers)
|
||||||
timings["range_retry_attempts"] = retry_attempts
|
timings["range_retry_attempts"] = retry_attempts
|
||||||
timings["range_retry_sleep_s"] = retry_sleep_s
|
timings["range_retry_sleep_s"] = retry_sleep_s
|
||||||
|
timings["range_failed_attempt_s"] = failed_attempt_s
|
||||||
|
timings["range_exception_attempts"] = exception_attempts
|
||||||
|
timings.update(exception_counts)
|
||||||
return payload, status_code, timings
|
return payload, status_code, timings
|
||||||
except self._RETRYABLE_EXCEPTIONS as exc:
|
except self._RETRYABLE_EXCEPTIONS as exc:
|
||||||
last_exc = exc
|
last_exc = exc
|
||||||
|
failed_attempt_s += time.perf_counter() - attempt_start
|
||||||
|
exception_attempts += 1.0
|
||||||
|
exception_key = f"range_exception_{type(exc).__name__}"
|
||||||
|
exception_counts[exception_key] = exception_counts.get(exception_key, 0.0) + 1.0
|
||||||
if attempt >= self.max_retries:
|
if attempt >= self.max_retries:
|
||||||
break
|
break
|
||||||
retry_attempts += 1.0
|
retry_attempts += 1.0
|
||||||
@@ -362,6 +373,9 @@ class NativeHTTPRangeFetcher:
|
|||||||
range_failed_requests=1.0,
|
range_failed_requests=1.0,
|
||||||
range_retry_attempts=retry_attempts,
|
range_retry_attempts=retry_attempts,
|
||||||
range_retry_sleep_s=retry_sleep_s,
|
range_retry_sleep_s=retry_sleep_s,
|
||||||
|
range_failed_attempt_s=failed_attempt_s,
|
||||||
|
range_exception_attempts=exception_attempts,
|
||||||
|
**exception_counts,
|
||||||
)
|
)
|
||||||
if last_exc is None:
|
if last_exc is None:
|
||||||
raise RuntimeError("HTTP range request failed without an exception")
|
raise RuntimeError("HTTP range request failed without an exception")
|
||||||
|
|||||||
Reference in New Issue
Block a user