SameerMesiah97 commented on code in PR #66269:
URL: https://github.com/apache/airflow/pull/66269#discussion_r3176826683


##########
task-sdk/src/airflow/sdk/__init__.pyi:
##########
@@ -51,13 +51,21 @@ from airflow.sdk.definitions.asset import (
 )
 from airflow.sdk.definitions.asset.decorators import asset as asset
 from airflow.sdk.definitions.asset.metadata import Metadata as Metadata
+from airflow.sdk.definitions.callback import (
+    AsyncCallback as AsyncCallback,
+    SyncCallback as SyncCallback,

Review Comment:
   Why are you importing `SyncCallback` here?  My understanding is that it is 
mid-rollout. Also, you are not using it in your example DAG. 



##########
airflow-core/src/airflow/example_dags/example_deadline_alert.py:
##########
@@ -0,0 +1,59 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Example DAG demonstrating :class:`~airflow.sdk.DeadlineAlert` usage."""
+
+from __future__ import annotations
+
+import logging
+from datetime import timedelta
+
+import pendulum
+
+# [START example_deadline_alert]
+from airflow.sdk import DAG, AsyncCallback, DeadlineAlert, DeadlineReference, 
task
+
+log = logging.getLogger(__name__)
+
+
+async def notify_deadline_missed(**kwargs):
+    """Async callback executed by the Triggerer when the deadline is missed."""
+    context = kwargs.get("context", {})
+    dag_run = context.get("dag_run")
+    log.warning("Deadline missed for dag_run=%s", dag_run)
+
+
+with DAG(
+    dag_id="example_deadline_alert",
+    description="Demonstrates DeadlineAlert with DAGRUN_LOGICAL_DATE 
reference.",
+    schedule=None,
+    start_date=pendulum.datetime(2025, 1, 1, tz="UTC"),
+    catchup=False,
+    tags=["example", "deadline"],
+    deadline=DeadlineAlert(
+        reference=DeadlineReference.DAGRUN_LOGICAL_DATE,
+        interval=timedelta(hours=1),

Review Comment:
   The interval is far too long for the task. This DAG will almost never 
trigger the DeadlineAlert. Perhaps you could make this 60 seconds and add a 2 
minute wait to the task? You need to do exactly this but my point is the 
running the example DAG should demonstrate the behaviour of the feature in 
question. 



##########
airflow-core/src/airflow/example_dags/example_deadline_alert.py:
##########
@@ -0,0 +1,59 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Example DAG demonstrating :class:`~airflow.sdk.DeadlineAlert` usage."""
+
+from __future__ import annotations
+
+import logging
+from datetime import timedelta
+
+import pendulum
+
+# [START example_deadline_alert]
+from airflow.sdk import DAG, AsyncCallback, DeadlineAlert, DeadlineReference, 
task
+
+log = logging.getLogger(__name__)
+
+
+async def notify_deadline_missed(**kwargs):
+    """Async callback executed by the Triggerer when the deadline is missed."""
+    context = kwargs.get("context", {})
+    dag_run = context.get("dag_run")
+    log.warning("Deadline missed for dag_run=%s", dag_run)
+
+
+with DAG(
+    dag_id="example_deadline_alert",
+    description="Demonstrates DeadlineAlert with DAGRUN_LOGICAL_DATE 
reference.",
+    schedule=None,
+    start_date=pendulum.datetime(2025, 1, 1, tz="UTC"),
+    catchup=False,
+    tags=["example", "deadline"],
+    deadline=DeadlineAlert(
+        reference=DeadlineReference.DAGRUN_LOGICAL_DATE,

Review Comment:
   I am not sure if `DAGRUN_LOGICAL_DATE` is the best reference to use as it 
can result in weird behavior for delayed runs. Have you considered using 
`DAGRUN_QUEUED_AT` instead?



-- 
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]

Reply via email to