Lesson 4 of 9 · 25m
Orchestration and Dependencies: Make Time and Data Flow Explicit
Model pipelines as dependency graphs with deterministic partitions, clear ownership, retries, and separation between scheduling and business logic.
Cron works right up until two jobs overlap, one dependency is late, and nobody knows whether the dashboard is empty because input was late or because the transform failed. Orchestration exists to answer four boring questions: what must run, in what order, with what inputs, and what do we do when part of it fails? If your tooling cannot answer those questions, the pipeline is held together by hope and shell scripts.
Model data dependencies, not just task order
A dependency should mean "the required input partition exists and is valid," not merely "the upstream process exited zero."
from airflow import DAG
from airflow.operators.python import PythonOperator
with DAG("daily_revenue", schedule="0 6 * * *", catchup=False):
transform = PythonOperator(task_id="transform_orders", python_callable=transform_orders, op_kwargs={"day": "{{ ds }}"})
publish = PythonOperator(task_id="publish_metrics", python_callable=publish_metrics, op_kwargs={"day": "{{ ds }}"})
transform >> publish # publish checks the input partition contractThe critical contract is inside the publish task: verify the partition before using it. Exit codes are not data contracts.
Keep business logic outside the scheduler
Airflow, Dagster, Prefect, and friends should orchestrate. They should not contain the entire transformation embedded in a task because somebody found it convenient.
orchestrator dependency graph, retries, alerts, backfills, ownership
job runtime transformation, validation, write semantics
warehouse storage, constraints, query performanceMixing those roles makes both testing and migration painful. Put transformation logic in tested modules, SQL projects, or versioned jobs; pass logical date, environment, and input locations explicitly.
Retries need jitter, bounds, and idempotent tasks
Retries are safe only after writes are idempotent. Otherwise the orchestrator is very good at corrupting data repeatedly.
default_args = {
"retries": 3,
"retry_delay": timedelta(minutes=5),
"retry_exponential_backoff": True,
"max_retry_delay": timedelta(minutes=30),
}Ownership belongs beside retry policy: every task needs an owner, severity, expected duration, and failure consequence. Fraud blocking and a weekly marketing export do not deserve the same alert path.
Sensors are a smell when overused
Polling for an upstream table can be necessary, but long chains of sensors create idle workers, hidden coupling, and timeouts nobody understands. Prefer event-driven handoff, explicit partitions, or a shared dependency manifest:
{"dataset":"warehouse/orders","partition":"dt=2026-03-14","row_count":1823441,"status":"validated"}The manifest turns "the process finished" into "the data is ready."
Field notes
catchup=Truecan launch years of backfill unexpectedly after a pause or redeploy. Know the setting before enabling a DAG.- Logical date is not wall-clock runtime. Pass the logical partition explicitly through every task.
- Avoid dynamic task generation based on mutable warehouse contents; graphs become impossible to audit.
- A green DAG means tasks completed, not that the data is correct. Pair orchestration with validation gates.
Was this lesson helpful?