Overview
Airflow 2.1, released on May 22, 2021, introduces cross-DAG dependencies and a calendar view to better visualize scheduled runs.
Main Features
Cross-DAG dependencies
The ExternalTaskSensor and cross-DAG dependencies let you create pipelines where one DAG waits for a task in another DAG to complete before running.
python
from airflow import DAG
from airflow.operators.python import PythonOperator
from airflow.sensors.external_task import ExternalTaskSensor
from datetime import datetime
with DAG('consumer_dag', start_date=datetime(2021, 1, 1)) as dag:
# Wait for the producer DAG to finish
wait = ExternalTaskSensor(
task_id='wait_for_extraction',
external_dag_id='producer_dag',
external_task_id='extract_data',
timeout=3600,
)
process = PythonOperator(
task_id='process',
python_callable=lambda: print('Processing'),
)
wait >> process
Calendar view
The new calendar view in the web interface displays DAG runs on a monthly calendar, making it easy to identify failures and execution trends.
python
from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime, timedelta
# Daily DAG visible in the calendar view
with DAG(
'daily_report',
start_date=datetime(2021, 1, 1),
schedule_interval='@daily',
catchup=False,
) as dag:
generate = PythonOperator(
task_id='generate_report',
python_callable=lambda: print('Report generated'),
)
