Overview

Airflow 2.3, released on May 1, 2022, introduces dynamic task mapping and the grid view for better DAG visualization.

Main Features

Dynamic task mapping

Dynamic task mapping creates a variable number of tasks at runtime, replacing complex dynamic DAG generation patterns.

python
from airflow.decorators import dag, task
from datetime import datetime

@dag(schedule_interval='@daily', start_date=datetime(2022, 1, 1))
def etl_pipeline():
    @task
    def extract():
        return ['file1.csv', 'file2.csv', 'file3.csv']

    @task
    def transform(file: str):
        return f'processed_{file}'

    files = extract()
    transform.expand(file=files)  # dynamic mapping

etl_pipeline()

Grid view

The new grid view replaces the tree view and offers better visualization of task execution history.

python
from airflow.decorators import dag, task
from datetime import datetime

@dag(schedule_interval='@hourly', start_date=datetime(2022, 1, 1))
def monitoring():
    @task
    def check_health():
        return {'status': 'ok'}

    @task
    def notify(result: dict):
        if result['status'] != 'ok':
            print('Alert!')

    result = check_health()
    notify(result)
# Grid view visible in the web interface

Sources