Skip to content

Add example DAG demonstrating Deadline Alerts #66268

@rapsealk

Description

@rapsealk

Description

Deadline Alerts shipped in Airflow 3.1, with UI improvements (deadlineStatus panel) in 3.2. The feature is documented in `docs/howto/deadline-alerts.rst`, but no runnable example DAG ships in `airflow-core/src/airflow/example_dags/`. Every other major DAG-authoring feature (assets, branching, dynamic task mapping, params, setup/teardown, etc.) has at least one example DAG there.

This makes it harder for users to:

Proposal

Add `airflow-core/src/airflow/example_dags/example_deadline_alert.py` that:

  • Uses `DeadlineReference.DAGRUN_LOGICAL_DATE` with a 1-hour interval.
  • Defines an in-file async callback (no provider dependency).
  • Wraps the body in `[START example_deadline_alert]` / `[END example_deadline_alert]` markers so a follow-up can replace the inline snippet in `deadline-alerts.rst` with a `literalinclude`.

Out of scope (follow-up)

  • Replacing the inline snippet in `deadline-alerts.rst` with `literalinclude` of the new file.
  • Examples for the other reference types (`DAGRUN_QUEUED_AT`, `FIXED_DATETIME`, `AVERAGE_RUNTIME`).

Side fix discovered

`task-sdk/src/airflow/sdk/init.pyi` is missing several names that exist at runtime in `init.py`:

  • `AsyncCallback`, `SyncCallback` (from `.definitions.callback`)
  • `DeadlineAlert`, `DeadlineReference` (from `.definitions.deadline`)

Importing them via the documented path `from airflow.sdk import DeadlineAlert` triggers `attr-defined` errors under mypy. This blocks the example DAG from passing static checks. The fix is mechanical (add the missing imports + `all` entries) and will be included in the same PR.


Drafted-by: Claude Code (Opus 4.7) (no human review before posting)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions