Project
Stage 2 project: Acme Shipments Pipeline
Everything from Stage 2 as one pipeline: extract through retries and the rate limit, validate with quarantine, load idempotently, and prove source and target agree before anyone says "done".
Time: ~3–4 hours if you build it yourself (recommended). Run the reference version:
PYTHONPATH=tools .venv/bin/python stage-2-data-integration/project-shipments-pipeline/shipments_pipeline.py
Core (build this)
- Extract every shipment from the simulated API through pagination, the 503 and the 429 (Part 5's client).
- Validate each record with a Pydantic schema; quarantine failures with reasons (Part 6).
- Load with the timestamp-guarded upsert, and run the load twice to prove idempotency (Part 7).
- Reconcile source against target — counts, missing, extra, mismatched — and print one run report.
Stretch
- Make it incremental with a watermark saved after the load, plus a backfill mode that chunks history and respects the rate limit (Part 8).
- Add run reports as files (one JSON per run) and an alert when a run loads unusually few rows.
Production level
- Schedule it (cron entry or the customer's scheduler), write the runbook ("if the 3am run fails: run it again; here is why that is safe"), and add pytest tests that use the simulated API to force every error path: 401, 429, 503, invalid record, duplicate batch.
What "done" looks like
- All 8 rows arrive despite a 503 and a 429 on the way (5 requests for 3 pages).
- A second load changes nothing.
- The reconciliation prints three empty lists — and you can explain why each list matters.
The reference implementation is shipments_pipeline.py; its output below came from a real run.
{'extracted': 8, 'requests': 5, 'valid': 8, 'quarantined': 0, 'rows_in_table': 8}
reconciliation: {'missing': [], 'extra': [], 'mismatched': []}
(The API data is clean by design — the messy export was Part 6's battle. The pipeline still validates every record, because the customer's next feed will not be clean.)