Add generic bounded-retry helper for source-adapter network IO - #6
Merged
Conversation
Add a non-Azure with_retries/is_transient helper in src/parce/sources/_retry.py (exponential backoff, full jitter) and wrap the CELLxGENE Census and EuropePMC network IO with it. Transient detection covers stdlib timeout/connection/OS errors plus requests connection/timeout errors and HTTP 429/5xx; requests exceptions are classified first since they subclass OSError. Update the stale CLAUDE.md resilience reference and add offline tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts: # docs/ROADMAP.md # src/parce/sources/__init__.py
The post-merge rename left the test importing/patching the deleted parce.tools.ncbi_fetcher module; point it at the new sources.publication path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a small, generic (non-Azure) bounded-retry-with-jittered-backoff helper and wires it into the source adapters' network IO.
src/parce/sources/_retry.py—with_retries(func, ...)+is_transient(exc). Exponential backoff with full jitter, dependency-neutral (no Azure, no Census coupling). Lives insources/so it's mypy-checked stable core and reusable by the GEO (PR 5) and PRIDE (PR 7) adapters.sources/cellxgene.py— wrapsopen_soma, the datasets table read,get_obs, andget_source_h5ad_uri.sources/publication.py— wrapsrequests.getandraise_for_status()together inside the retried call, so a 429/5xx is retried rather than raised straight out.CLAUDE.md— updated the stale resilience reference (it pointed at "the existing helpers inmain.py") to the newsources/_retry.py.tests/test_retry.py(transient classification + retry/exhaustion,time.sleeppatched) andtests/test_publication.py(offline 503 / connection-error → success wiring).Why
PR 3 removed the Azure-keyed
_is_transient/_backoff_delayhelpers frommain.pyalong with the LLM call (their only caller), leaving the CELLxGENE/EuropePMC network IO with no retry/backoff. PR 3's own session log flagged this as a follow-up; this PR closes it. It's an out-of-band resilience fix, not a roadmap PR — Next up stays PR 4.Reviewer notes
TimeoutError/ConnectionError/OSError,requestsconnection/timeout errors, andrequestsHTTPError with 429/5xx.requestsexception subclassesOSError, so a naive "OSError → transient" check would wrongly retry a 404 or a malformed-URL error.is_transienttherefore classifiesrequestsexceptions first (by kind / status code) and only falls back to the stdlib check for non-requestserrors. This is covered by tests (HTTPError(404)andMissingSchema/InvalidURLassert non-transient).sources/__init__.py(took PR 3's) anddocs/ROADMAP.md(kept both session-log entries) were resolved by hand.Gates
All four pass locally, including the hermetic run with
.envmoved aside:ruff check·ruff format --check·mypy src/parce(17 files) ·pytest -m "not integration"→ 71 passed.🤖 Generated with Claude Code