Repository navigation
refactor(pipeline): Fetch all inputs up front, in parallel - #831
Merged
Merged
Conversation
The pipeline now starts with a single `fetch_inputs` step that downloads AllThePlaces and the OpenStreetMap planet concurrently (sub-steps `fetch_inputs.atp` / `fetch_inputs.osm`). If one fetch fails, the others are cancelled and the run aborts before any processing. `import_atp` and `import_osm` now work only on local files. - `fetch_planet` is async (no nested runtime) and hashes the planet while streaming, including the already-downloaded prefix of a resumed `.part` file, instead of re-reading ~90GB afterwards. - Cache rule, documented in `pipeline::inputs`: an input is reused when its metadata sidecar exists together with either the raw file or the artifact derived from it (`alltheplaces.parquet`, `osm-features.index`). A sidecar-less `.pbf` (regional extract) is still accepted. - The release date is derived right after `fetch_inputs`, from the fetched metadata. - Cancelled steps still log an `end` snapshot plus a warning. Output is unchanged: on the fixtures, conflated.parquet, the tiles, datapackage.json and the BOM are byte-identical to the previous version. Closes #830 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WtzCoNtkdZsv5JqAkTcU6j
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.
Closes #830.
Summary
The pipeline now starts with a single
fetch_inputsstep that downloads every external input concurrently, before any processing. Every later step works only on local files. This is a refactor: no output changes.src/pipeline/inputs.rs.fetch_inputsruns the AllThePlaces and planet fetches withtry_join, each logged as its own sub-step (fetch_inputs.atp,fetch_inputs.osm) with timings. If one fails, the others are cancelled immediately and the run aborts. A cancelled fetch still logs itsendsnapshot plus a "cancelled" warning, through a newrun_step_asyncthat shares its logging withrun_step. The runtime is shut down withshutdown_background(), so a cancelled fetch's blocking hash work isn't waited on.import_atp/import_osmnow take the fetchedInput(local path plus metadata) instead of an HTTP client, and no longer download anything.import_atpis no longer async. Theimport_osm.fetchsub-step is gone; that work is nowfetch_inputs.osm.fetch_planetis async: no nested runtime, and blocking work runs inspawn_blocking. It now hashes while streaming, which saves a full ~90 GB read pass. A resumed.partdownload first hashes the prefix already on disk.fetch_inputsfrom the fetched metadata (provenance::anchor_timestamp).read_anchoris removed.Cache rule (module doc of
pipeline::inputs)Per input, nothing is downloaded if the metadata sidecar exists and either the raw file or the artifact derived from it (
alltheplaces.parquet/osm-features.index) exists. In the second case,Input::pathdoesn't exist, and the downstream step reuses its artifact. A planet.pbfwithout a sidecar (a regional extract forscripts/test-on-hetzner) is still accepted, and its metadata is computed on the spot.One behavioural tightening:
import_atpnow rebuildsalltheplaces.parquetwhenalltheplaces.zipexists and is newer than it. This mirrorsimport_osm's existing mtime check. It guards against an old parquet being reused after the zip was downloaded again, which the new cache rule can cause when the sidecar is missing.Tests
inputs:fetch_inputsfail well within the test's 30 s limit and leaves no downloaded files. With no request timeout on the planet download, only cancellation can end that fetch.osm::fetch:.pbfwithout a sidecar is accepted (now async);Range/206) hashes the whole file, checked againstutils::hash_file.atp::fetch: the parquet stands in for a deleted zip, but only together with its sidecar.Run locally:
cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo testare clean, includingtest_pipelineandtest_reproducible_artifacts.mainand this branch, run on the fixtures in the same workdir path, give byte-identicalconflated.parquet, all.pmtiles,datapackage.jsonand the BOM..pmtilesfiles (and thereforedatapackage.json) differ by one byte onmaintoo. The tiles seem to depend on the workdir path.test_reproducible_artifactsdoesn't catch this.Docs
docs/TECHNICAL_DESIGN.md: an "Inputs" box and thefetch_inputsstep in the diagram, and the step list updated.docs/LOGGING.mdanddocs/PRODUCTION.md: step names updated. A note says the--mem-limittable'simport_osmtimings still include the download.scripts/test-on-hetzner/remote/fetch_test_extract.sh: a comment updated.🤖 Generated with Claude Code
https://claude.ai/code/session_01WtzCoNtkdZsv5JqAkTcU6j
Generated by Claude Code