Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(tests): retry full source fetch on transient network errors in release-gate (#3754)

LearningCircuit9a8050f98f79
diff --git a/tests/integration/test_journal_quality_release_gate.py b/tests/integration/test_journal_quality_release_gate.py
index cc960e86a2..91c434da20 100644
--- a/tests/integration/test_journal_quality_release_gate.py
+++ b/tests/integration/test_journal_quality_release_gate.py
@@ -50,10 +50,13 @@ from __future__ import annotations
import gzip
import json
+import time
from concurrent.futures import ThreadPoolExecutor, as_completed
from pathlib import Path
import pytest
+import requests.exceptions
+from loguru import logger
pytestmark = [
@@ -95,12 +98,47 @@ def downloaded_data_dir(tmp_path_factory) -> Path:
errors: dict[str, str] = {}
counts: dict[str, int] = {}
+ # Transient network errors that warrant a full-source retry. The
+ # per-partition download in ``iter_partitions`` already retries
+ # individual partitions with a 2-5-10-20-40 s backoff (5 attempts).
+ # If even that budget is exhausted (e.g. a sustained S3 outage >
+ # ~75 s), we retry the *entire* source from scratch — fresh TCP
+ # connections, fresh manifest, fresh partition list — up to 3 times.
+ _TRANSIENT_ERRORS = (
+ requests.exceptions.ChunkedEncodingError,
+ requests.exceptions.ConnectionError,
+ requests.exceptions.Timeout,
+ ConnectionResetError,
+ ConnectionAbortedError,
+ BrokenPipeError,
+ )
+ _FETCH_MAX_RETRIES = 3
+ _FETCH_BACKOFF_SECONDS = (30, 60, 120)
+ assert len(_FETCH_BACKOFF_SECONDS) == _FETCH_MAX_RETRIES, (
+ "backoff tuple length must match retry count"
+ )
+
def _fetch_one(src):
- try:
- n = src.fetch(tmp_dir)
- return src.key, n, None
- except Exception as e: # noqa: BLE001 — surface every failure
- return src.key, 0, repr(e)
+ for attempt in range(1 + _FETCH_MAX_RETRIES):
+ try:
+ n = src.fetch(tmp_dir)
+ return src.key, n, None
+ except _TRANSIENT_ERRORS as e:
+ if attempt < _FETCH_MAX_RETRIES:
+ wait = _FETCH_BACKOFF_SECONDS[attempt]
+ logger.warning(
+ f"Source {src.key} failed (attempt {attempt + 1}/"
+ f"{1 + _FETCH_MAX_RETRIES}): {e!r} — retrying in {wait}s"
+ )
+ time.sleep(wait)
+ continue
+ logger.exception(
+ f"Source {src.key} exhausted all "
+ f"{1 + _FETCH_MAX_RETRIES} retries"
+ )
+ return src.key, 0, repr(e)
+ except Exception as e: # noqa: BLE001 — surface every failure
+ return src.key, 0, repr(e)
# All five in parallel. max_workers=5 lets each source own a thread
# and run end-to-end without blocking on its peers.