refactor(download): split the download.py god module into a package#121
Merged
Conversation
Split the 1889-line dataset/download.py into a download/ package (constants, fetch, listing, extract, cache_io, core) with __init__ re-exporting the public API so all existing imports keep working. Pure code-move: all 31 defs preserved, verified via identical def inventory, full import graph, ruff, and the parquet test.
Merged
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.
Splits the 1889-line
dataset/download.pyinto a cohesivedownload/package. Pure code-move — no logic changes.Structure
constants(errors, extensions, archive-type predicates) ←fetch(HTTP/HF downloading) /listing(remote enumeration + URL resolution) /extract(parquet/tar/zip/raw decode) /cache_io(persistent-cache load) ←core(download_and_extractorchestration, incl. gasstation).download/__init__.pyre-exports the public API, so every existingfrom ...dataset.download import Xkeeps working unchanged (verified against all call sites:iterator.py,gasstation_utils.py,dataset/__init__.py, and the parquet test).How it was done (low-risk)
sed), so they are byte-identical to the original — no hand-editing of logic.F821(undefined-name) told me exactly which sibling each module needed;F401 --fixtrimmed the shared header down per module.constants ← {fetch, listing, extract, cache_io} ← core.Verification
diffempty — nothing dropped or duplicated.ruff check src testsclean.test_parquet_processing.py: 12/12 pass. Full unit suite: 46 pass, same 5 pre-existingtest_config_loadingdata-drift failures (unrelated).Note
The
_process_*/list_*helper names (incl. the leading-underscore ones) are preserved verbatim to avoid touching call sites; a follow-up could tidy naming/visibility now that they're grouped, but that would no longer be a pure move.