Airflow Cheat Sheet
A cheat sheet for Apache Airflow covering DAG authoring with the TaskFlow API, operators, task dependencies, and essential CLI commands.
2 PagesIntermediateMar 12, 2026
TaskFlow API DAG
Define a DAG with Python-native task decorators.
python
from airflow.decorators import dag, taskfrom datetime import datetime@dag(schedule='@daily', start_date=datetime(2024, 1, 1), catchup=False)def etl_pipeline(): @task def extract(): return {'rows': 100} @task def transform(data): data['rows'] *= 2 return data @task def load(data): print(f"Loaded {data['rows']} rows") load(transform(extract()))etl_pipeline()
Classic Operators
Traditional operator-based DAG with explicit dependencies.
python
from airflow import DAGfrom airflow.operators.python import PythonOperatorfrom airflow.operators.bash import BashOperatorfrom datetime import datetimewith DAG('classic_dag', start_date=datetime(2024, 1, 1), schedule='0 6 * * *') as dag: t1 = BashOperator(task_id='print_date', bash_command='date') t2 = PythonOperator(task_id='say_hi', python_callable=lambda: print('hi')) t1 >> t2 # t1 must run before t2
CLI Commands
Manage the webserver, scheduler, and DAG runs.
bash
airflow webserver -p 8080 # Start the UIairflow scheduler # Start the schedulerairflow dags list # List all DAGsairflow dags trigger etl_pipeline # Manually trigger a DAG runairflow tasks test etl_pipeline extract 2024-01-01 # Test a single task
Core Concepts
Key Airflow terminology.
- DAG- Directed Acyclic Graph describing task dependencies and a schedule
- Operator- Template for a single task, e.g. BashOperator, PythonOperator, KubernetesPodOperator
- Task Instance- A specific run of a task for a given execution/logical date
- XCom- Mechanism for passing small pieces of data between tasks
- Sensor- Special operator that waits for a condition, like a file arriving, before continuing
- Executor- Determines how tasks run: LocalExecutor, CeleryExecutor, or KubernetesExecutor
Pro Tip
Keep DAG files lightweight and free of heavy top-level computation or database calls — the scheduler re-parses every DAG file on a short interval, so slow imports or expensive logic at import time will bottleneck the entire scheduler, not just one DAG.
Was this cheat sheet helpful?
Explore Topics
#Airflow#AirflowCheatSheet#DataScience#Intermediate#TaskFlowAPIDAG#ClassicOperators#CLICommands#CoreConcepts#MachineLearning#APIs#CommandLine#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance