Project Workshop — ETL Pipeline with Canvas
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important…
- What you are building
- Architecture
- Acceptance criteria
- Suggested repository structure
- Build plan: vertical slices
Celery · Canvas · Beat · Redis
Expected effort: 5–8 focused hours · Minimum meaningful tests: 12What you are building
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important design decision from the README.
Architecture
Critical interaction
Ownership table
| Boundary | Owns | Must not own |
|---|---|---|
| Interface | Parsing, protocol validation, identity extraction, status or presentation mapping | Core business invariants |
| Application/domain | Authorization inputs, state transitions, orchestration, transaction intent | Framework globals or raw transport objects |
| Repository/gateway | One persistence or external protocol, bounded retries, error translation | Product policy |
| Background/UI projection | Recoverable derived state and delivery progress | Hidden authoritative truth |
| Operations | Configuration, health, deployment, telemetry, recovery | Business decisions encoded only in dashboards |
Acceptance criteria
| ID | Required behavior | Evidence |
|---|---|---|
| AC-1.1 | chain() sequential pipeline produces the specified behavior inside Canvas: chains, groups, chords | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.2 | group() parallel execution produces the specified behavior inside Canvas: chains, groups, chords | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.3 | chord() parallel→single callback produces the specified behavior inside Canvas: chains, groups, chords | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.4 | Signature objects with s()/si() produces the specified behavior inside Canvas: chains, groups, chords | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.1 | multiple queues (default/high/low) produces the specified behavior inside Priority queues & DLQ | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.2 | routing tasks to specific queues produces the specified behavior inside Priority queues & DLQ | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.3 | worker -Q flag produces the specified behavior inside Priority queues & DLQ | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.4 | dead letter queues for failed tasks produces the specified behavior inside Priority queues & DLQ | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.1 | autoretry_for: auto-retry on exception types produces the specified behavior inside Error handling & retries | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.2 | max_retries + retry_backoff (exponential) produces the specified behavior inside Error handling & retries | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.3 | on_failure/on_retry/on_success callbacks produces the specified behavior inside Error handling & retries | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.4 | idempotency: safely retried task design produces the specified behavior inside Error handling & retries | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.1 | starmap for argument tuples produces the specified behavior inside Bulk Canvas operations | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.2 | chunks for bounded batches of 10k records produces the specified behavior inside Bulk Canvas operations | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.3 | immutable si signatures in chains produces the specified behavior inside Bulk Canvas operations | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.4 | chord error callback and result-backend pressure produces the specified behavior inside Bulk Canvas operations | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
Suggested repository structure
1project/2├── src/{producer.py,consumer.py,models.py,handlers.py,idempotency.py}/3├── contracts/{schemas,retry-envelope}/4├── config/5├── tests/{unit,integration,rebalance,failure}/6├── compose.yaml7├── pyproject.toml8└── runbooks/Build plan: vertical slices
| Milestone | Capability | First implementation | Exit condition |
|---|---|---|---|
| 1 | Canvas: chains, groups, chords | chain() sequential pipeline; group() parallel execution; chord() parallel→single callback | Demonstration plus focused tests |
| 2 | Priority queues & DLQ | multiple queues (default/high/low); routing tasks to specific queues; worker -Q flag | Demonstration plus focused tests |
| 3 | Error handling & retries | autoretry_for: auto-retry on exception types; max_retries + retry_backoff (exponential); on_failure/on_retry/on_success callbacks | Demonstration plus focused tests |
| 4 | Bulk Canvas operations | starmap for argument tuples; chunks for bounded batches of 10k records; immutable si signatures in chains | Demonstration plus focused tests |
| 5 | Hardening and delivery | Security, recovery, telemetry, performance, documentation | Full acceptance suite and recorded demonstration |
For each milestone, first create a failing acceptance test or a reproducible command. Implement the thinnest path to an observable result, add the nearest durable invariant, inject one expected failure, and refactor only after evidence protects the behavior.
Reference vertical slice
1from celery import chain, chord, group2
3extract = group(extract_chunk.s(job_id, chunk_id) for chunk_id in chunk_ids)4workflow = chord(extract)(5 chain(6 merge_chunks.s(job_id),7 validate_output.s(),8 publish_dataset.s(job_id),9 )10)11print(workflow.id)Expected result
1Chunks execute in parallel; only after all succeed does the callback merge, validate, and publish.Code reading
| Line | Code | Explanation |
|---|---|---|
| 1 | from celery import chain, chord, group | Imports the named dependency; import executes the module once per interpreter cache and binds selected names here. |
| 3 | extract = group(extract_chunk.s(job_id, chunk_id) for chunk_id in chunk_ids) | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 4 | workflow = chord(extract)( | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 5 | chain( | Implements the next python statement in the example's data flow. |
| 6 | merge_chunks.s(job_id), | Implements the next python statement in the example's data flow. |
| 7 | validate_output.s(), | Implements the next python statement in the example's data flow. |
| 8 | publish_dataset.s(job_id), | Implements the next python statement in the example's data flow. |
| 9 | ) | Implements the next python statement in the example's data flow. |
| 10 | ) | Implements the next python statement in the example's data flow. |
| 11 | print(workflow.id) | Emits the example's observable output. |
Risk register
| Area | Failure to reproduce | Required design response |
|---|---|---|
| Canvas: chains, groups, chords | Large chords stress result backends and one failed header can block the callback. | Keep each stage independently idempotent and persist workflow state for important jobs. |
| Priority queues & DLQ | Priority cannot preempt work already reserved or executing. | Use separate workers for hard isolation and record an error envelope with original identity. |
| Error handling & retries | Retrying validation errors or non-idempotent external writes can amplify damage. | Retry transient failures only and cap attempts and total age. |
| Bulk Canvas operations | Large chords stress result backends and one failed header can block the callback. | Keep each stage independently idempotent and persist workflow state for important jobs. |
Engineering checklist for this stack
- To do: assign stable message and operation identities
- To do: acknowledge only after the intended durable outcome
- To do: make handlers idempotent
- To do: bound retry and route terminal failures
- To do: monitor age, lag, duplicates, and stranded work
Test strategy
Implement at least 12 meaningful cases. A long list of shallow happy-path tests does not satisfy the requirement.
| Risk class | Minimum | Examples |
|---|---|---|
| Happy path and contract | 2 | Correct output, status/schema, durable state |
| Validation and boundaries | 2 | Empty, malformed, extreme, unsupported transition |
| Authorization or trust boundary | 1 | Missing identity, wrong tenant/role, injection or unsafe content |
| Failure and recovery | 2 | Timeout, retry, rollback, reconnect, dependency outage |
| Duplicate or concurrency | 1 | Same identity twice, racing update, redelivery |
| Performance and operations | 4 | Query bound, lag, p95, resource limit, telemetry |
Representative test scaffold
1def test_redelivery_has_one_logical_effect(harness):2 event = make_event(event_id="evt-1")3 harness.deliver(event)4 harness.crash_after_side_effect_before_commit()5 harness.deliver(event)6 assert harness.domain_effect_count("evt-1") == 17 assert harness.committed_offset_is_after(event)8
9def test_permanent_failure_reaches_dlt(harness):10 harness.deliver(make_invalid_event(event_id="evt-bad"))11 assert harness.dlt_envelope("evt-bad")["attempts"] >= 1Failure drills
- Stop the primary external dependency during the critical path. Capture the failure, cleanup, telemetry, and recovery.
- Repeat the same operation with the same stable identity. Prove one logical outcome or document why repetition is forbidden.
- Crash after durable state changes but before the response, acknowledgement, or projection. Re-run and reconcile.
- Submit the largest supported input and one slightly larger input.
- Remove one permission and prove denial without state change or information leakage.
- Roll back the change or restore the dependency, then run a smoke test and reconciliation check.
Performance experiment
State the dataset, payload distribution, concurrency, rate, duration, cache state, and resource limits before measuring. Publish p50, p95, p99, throughput, error rate, and the technology-specific correctness signal such as query count, consumer lag, duplicate effects, rendered updates, token cost, or recall. Change one variable at a time and retain raw output.
Submission package
- Complete source with a locked/reproducible environment.
- README.md with problem, architecture, setup, commands, configuration, assumptions, and trade-offs.
- Acceptance and risk-focused tests with a short explanation of what mocks intentionally do not cover.
- One design record explaining the most consequential choice and a rejected alternative.
- Security notes, sample non-secret configuration, and cleanup commands.
- A demonstration record: terminal transcript, screenshots, trace, query plan, or metrics dashboard.
- A 5–8 minute walkthrough following input → validation → state → failure → evidence.
Grading rubric
| Dimension | Weight | Full-credit evidence |
|---|---|---|
| Product behavior | 25 | Acceptance criteria pass through real public boundaries |
| Architecture and ownership | 20 | Responsibilities and state authority are explicit |
| Tests and recovery | 20 | Important negative, duplicate, concurrent, and outage cases pass |
| Security and data correctness | 15 | Least privilege, validation, constraints, and secret handling are demonstrated |
| Performance and operations | 10 | Reproducible measurement, useful telemetry, and rollback/recovery |
| Documentation and explanation | 10 | A new reviewer can reproduce and defend the result |
Mastery check
How well can you recall this?
Finished this lesson?