youngduck98 opened a new pull request, #75608:
URL: https://github.com/apache/airflow/pull/75608
Deadline alerts currently apply to every Dag run type, which can produce
unwanted notifications during historical backfills. This adds an optional
`run_type_filter` to let each alert select the run types it should monitor.
For example, an alert can apply to scheduled and asset-triggered runs:
```python
from airflow.sdk import DagRunType
DeadlineAlert(
reference=DeadlineReference.DAGRUN_LOGICAL_DATE,
interval=timedelta(hours=2),
callback=AsyncCallback(notify_deadline_missed),
run_type_filter={DagRunType.SCHEDULED, DagRunType.ASSET_TRIGGERED},
)
```
### Behavior
- Omitting the filter or using `None` preserves the existing behavior of
applying to all run types. Empty collections and unknown run types are rejected.
- Excluded runs do not create deadline records or resolve the excluded
alert's interval. Each alert on a Dag can use a different filter.
- The Dag overview shows which run types each alert applies to. Excluded
runs no longer show a misleading "Met" deadline status.
- Runs with existing deadline records continue to display their recorded
results, even if the filter later changes. The Deadlines list continues to show
stored records.
- The filter is serialized and persisted on alert definitions, with a
nullable-column migration in the 3.5.0 migration chain. `DagRunType` is exposed
through `airflow.sdk`.
### Try the example
With example Dags enabled, use `example_deadline_alert_run_type_filter` from
`example_deadline_alert.py`:
1. Unpause the Dag and trigger a manual run. The scheduler can also create a
scheduled run.
2. Each included run creates one deadline. The task waits for 60 seconds, so
its 30-second deadline is missed and the logging callback runs; the task itself
succeeds.
3. Create a backfill for a single past date after the Dag's start date. It
executes the same task without creating a deadline record, and the run header
has no deadline field.
4. Open the Dag's deadline-alert badge to see the Scheduled and Manual scope.
The original unfiltered example remains available. Local preview launchers
and runtime data are not included in this PR.
### Validation
- Regular and manual prek checks passed, including core/SDK type checks and
the SQLite migration round-trip check.
- Focused SDK, core deadline/serialization/version, UI API, and migration
tests passed. The example import and parse-time database-query checks passed (2
tests).
- Full core UI suite: 2,172 passed, 4 skipped.
- Local scheduled/manual/backfill comparison: included runs created
deadlines and completed their callbacks successfully; the excluded backfill
created no deadlines.
- Deadline encoding microbenchmark: 4.095 to 4.169 microseconds/call
(+1.8%); control +0.6%.
The full core/provider suites and full documentation build have not been
completed locally; the results above do not claim a complete CI run.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Codex (GPT-6)
Generated-by: Codex (GPT-6) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
---
* Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
for more information. Note: commit author/co-author name and email in commits
become permanently public when merged.
---
Drafted-by: Codex (GPT-6) (no human review before posting)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]