refactor(ogc): clarify module boundaries - #346
Merged
thodson-usgs merged 1 commit intoAug 2, 2026
Merged
Conversation
thodson-usgs
added a commit
to thodson-usgs/dataretrieval-python
that referenced
this pull request
Jul 23, 2026
…tate Revert the live-view change (item 3 of DOI-USGS#346): restore exc.partial_frame / exc.partial_response as raise-time snapshots rather than properties that delegate to exc.call. Snapshot is the better contract for an exception — a record of the failure moment, not a live handle: - In a resume loop each interruption stays a faithful record of what it saw. Live-view aliased every exception to the one shared call, so after a second failure exc1.partial_frame and exc2.partial_frame returned the same (later) state. - After a successful resume, live-view's .partial_frame returned the COMPLETE result — a field named "partial" that no longer was. - Exception payloads shouldn't mutate after you catch them (cf. CalledProcessError.output). Removing the delegation also drops the properties and the _pickled_* / __getstate__ snapshot machinery it required: partial_frame/partial_response are plain instance attributes again, pickled by the base __getstate__ (net -21 lines in interruptions.py). No behavior change versus released main — this PR is unmerged, so live-view never shipped. DOI-USGS#346 is now a true no-behavioral-change refactor. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extract response and frame recombination into combining.py and colocate the private fetch/finalize contracts with ChunkedCall. Centralize transient classification while preserving retry, resumability, exception snapshot, deduplication, nested GeoJSON, and response metadata contracts. Add regression coverage for those behaviors. Align Ruff 0.16.1 across CI, pre-commit, and test metadata, and apply its Markdown code-fence formatting.
thodson-usgs
force-pushed
the
refactor/ogc-module-boundaries
branch
from
August 2, 2026 13:00
6101a34 to
f8e4efd
Compare
thodson-usgs
marked this pull request as ready for review
August 2, 2026 13:11
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.
Summary
Structural refactoring of the OGC chunking module to clarify responsibilities and reduce coupling. No behavioral changes — all existing tests pass (one test updated to reflect the live-view simplification in item 3).
Includes the perf commit from #345 as the base.
Changes
1. Extract
combining.pyfromplanning.py(item 2)Moves response/frame recombination helpers (
_combine_chunk_frames,_combine_chunk_responses,_merge_response,_lowest_remaining,_safe_elapsed,_QUOTA_HEADER) into a dedicatedcombining.py.planning.pyre-exports them for backwards compatibility.Rationale: planning.py was conflating "what to split" with "how to reassemble" — two concerns with different reasons to change.
2. Move
_Fetch/_Finalize/_passthrough_resultintochunking.py(item 3)These type aliases define
ChunkedCall's contract, not anything about interruptions. They lived ininterruptions.pyonly to break a circular import. Now they're inchunking.pywhere they belong.3. Simplify
ChunkInterruptedby dropping snapshot copies (item 5)ChunkInterrupted.__init__used to.copy()the partial frame at raise time soexc.partial_framewas a frozen snapshot separate fromexc.call.partial_frame(the live view). The distinction was subtle and unlikely to be used by callers (the primary pattern isexc.call.resume()), and cost a full-frame copy proportional to completed data.Now
partial_frameandpartial_responseare properties that delegate toself.call— same as the live view, no memory copy. Pickle still works (snapshots at serialize time).4. Unify error classification into shared
_classify_transienthelper (item 6)_classify_chunk_error(chain-walk) and_retryable(top-level only) shared ~80% of their logic. Created a shared_classify_transient(exc)that classifies a single exception, so adding a new transient type only needs one update.Deferred to follow-up PRs
gather_paginatedprimitive — unifyingChunkedCall._runandwateruse._fan_out(invasive; needs careful testing of the retry/interruption model)engine.py— separating request construction, pagination, and argument normalization (~750-line module with 3 concerns)