Build your first DAG
Create a DAG that runs daily, has catchup disabled, and prints a message in one Python task.
Data / Knowledge library
python-based workflow orchestrator for data pipelines
Airflow helps teams author, schedule, observe, and retry complex data workflows as code (DAGs) instead of fragile cron chains and manual runbooks.
2014: Started at Airbnb to manage growing ETL dependency complexity. 2015: Open-sourced by Airbnb. 2016: Entered the Apache Incubator. 2019: Graduated to Apache Top-Level Project. 2020: Airflow 2.0 delivered major scheduler/UI improvements and TaskFlow API.
Work through these exercises in order. Try the task before opening a reference.
Create a DAG that runs daily, has catchup disabled, and prints a message in one Python task.
Extend a 3-task pipeline (extract -> transform -> load). Add per-task retries and a 5-minute retry delay.
Create two DAGs where DAG B triggers from a Dataset updated by DAG A. Validate behavior in the UI.
Replace a long-polling sensor with a deferrable equivalent and explain worker-slot savings.
Set up pools, SLA/alerts, and a backfill-safe strategy for late-arriving data.
Retailers managing multi-channel inventory across physical stores and e-commerce platforms.
Manual reconciliation processes lead to data silos, delayed stock updates, and frequent overselling of out-of-stock items due to inconsistent batch processing.
Apache Airflow orchestrates the end-to-end data pipeline by defining workflows as Python code, ensuring consistent execution of extraction, transformation, and load tasks across disparate systems.
The flow shows the sequence of tasks from data extraction to final synchronization.
Source of truth for online sales
Python task to fetch logs
BashOperator for DB maintenance
Final update to inventory system
This code demonstrates defining a DAG with a Python task for extraction and a BashOperator for cleanup, linked by a dependency operator.
from airflow.sdk import DAG, task
from airflow.providers.standard.operators.bash import BashOperator
with DAG(dag_id='inventory_sync', schedule='@hourly'):
@task
def extract_online(): # Fetch e-commerce data
return 'data'
cleanup = BashOperator(task_id='db_cleanup', bash_command='rm -rf /tmp/old_logs')
extract_online() >> cleanup # Define dependencyImproved inventory accuracy and reduced manual intervention through reliable, automated, and observable pipeline execution.
Airflow is designed for batch-oriented workflows; it is not suitable for low-latency streaming requirements. Check this by verifying if the business requirement demands sub-second data propagation.