youngduck98 commented on code in PR #75608:
URL: https://github.com/apache/airflow/pull/75608#discussion_r4371344721
##########
task-sdk/src/airflow/sdk/__init__.py:
##########
@@ -50,6 +50,7 @@
"CronPartitionTimetable",
"DAG",
"DagRunState",
+ "DagRunType",
Review Comment:
This exposes the existing DagRunType enum through the public SDK so Dag
authors can configure run_type_filter with enum members rather than relying on
string literals or importing an internal module. It reuses the existing enum
rather than introducing a separate set of run types.
##########
airflow-core/src/airflow/serialization/definitions/dag.py:
##########
@@ -775,7 +775,7 @@ def _process_dagrun_deadline_alerts(
stored_alerts = [
(alert.id, alert.name, alert.reference, alert.interval,
alert.callback_def)
for alert in deadline_alert_records
- if alert
+ if alert and (alert.run_type_filter is None or orm_dagrun.run_type
in alert.run_type_filter)
Review Comment:
This is the core filtering logic. When a Dag run is created, each alert is
checked against the run type before its deadline is calculated and stored.
Alerts with no filter retain the existing behavior; alerts that exclude this
run type are skipped without creating deadline records.
##########
airflow-core/src/airflow/ui/src/pages/Run/Header.tsx:
##########
@@ -60,8 +61,16 @@ export const Header = ({ dagRun }: { readonly dagRun:
DAGRunResponse }) => {
const dagId = dagRun.dag_id;
const dagRunId = dagRun.dag_run_id;
- const { data: alertData } = useDeadlinesServiceGetDagDeadlineAlerts({ dagId
});
- const hasDeadlineAlerts = (alertData?.total_entries ?? 0) > 0;
+ const { data: alertData } = useDeadlinesServiceGetDagDeadlineAlerts({ dagId,
dagRunId, limit: 100 });
+ const { data: deadlineData } = useDeadlinesServiceGetDeadlines({
+ dagId,
+ dagRunId,
+ limit: 10,
+ orderBy: ["deadline_time"],
+ });
+ const hasDeadlineAlerts =
+ (deadlineData?.total_entries ?? 0) > 0 ||
+ (alertData?.deadline_alerts ?? []).some((alert) =>
isDeadlineAlertApplicable(alert, dagRun.run_type));
Review Comment:
Existing deadline records take precedence over the applicability check for
deciding whether to show the field. A run's recorded deadline results should
remain visible even when its alert definitions are no longer available.
##########
airflow-core/src/airflow/ui/src/pages/Run/Header.tsx:
##########
@@ -60,8 +61,16 @@ export const Header = ({ dagRun }: { readonly dagRun:
DAGRunResponse }) => {
const dagId = dagRun.dag_id;
const dagRunId = dagRun.dag_run_id;
- const { data: alertData } = useDeadlinesServiceGetDagDeadlineAlerts({ dagId
});
- const hasDeadlineAlerts = (alertData?.total_entries ?? 0) > 0;
+ const { data: alertData } = useDeadlinesServiceGetDagDeadlineAlerts({ dagId,
dagRunId, limit: 100 });
Review Comment:
Passing dagRunId makes the run view use the alert definitions from the Dag
version that created this run. Otherwise, a later filter change could alter the
displayed deadline status of historical runs.
--
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]