This is an automated email from the ASF dual-hosted git repository.
ferruzzi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 9f887794ef7 Fix incorrect code samples in the Deadline Alerts docs
(#70709)
9f887794ef7 is described below
commit 9f887794ef7ee405cffb6b6a3aeacef3c52724b6
Author: D. Ferruzzi <[email protected]>
AuthorDate: Thu Jul 30 10:29:14 2026 -0700
Fix incorrect code samples in the Deadline Alerts docs (#70709)
---
airflow-core/docs/howto/deadline-alerts.rst | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/airflow-core/docs/howto/deadline-alerts.rst
b/airflow-core/docs/howto/deadline-alerts.rst
index 8e729516fef..df09430862b 100644
--- a/airflow-core/docs/howto/deadline-alerts.rst
+++ b/airflow-core/docs/howto/deadline-alerts.rst
@@ -447,17 +447,19 @@ implement an ``_evaluate_with()`` method.
class MyQueuedReference(BaseDeadlineReference):
"""A custom reference evaluated when Dag runs are queued."""
- required_kwargs = {"custom_param"}
+ # Ask for the Dag run context values supplied by Airflow; see notes
below.
+ required_kwargs = {"dag_id", "run_id"}
def _evaluate_with(self, *, session: Session, **kwargs) -> datetime:
- custom_value = kwargs["custom_param"]
- # Use custom_value in your calculation
+ dag_id = kwargs["dag_id"]
+ run_id = kwargs["run_id"]
+ # Use dag_id and run_id in your calculation
return your_datetime
**Using a Custom Reference in a Dag**
-Once registered [see notes below], use your custom references in Dag
definitions like any other reference:
+Once registered, use your custom references in Dag definitions like any other
reference:
.. code-block:: python
@@ -467,7 +469,7 @@ Once registered [see notes below], use your custom
references in Dag definitions
with DAG(
dag_id="custom_reference_example",
deadline=DeadlineAlert(
- reference=DeadlineReference.MyCustomDecoratedReference(),
+ reference=DeadlineReference.MyCustomDecoratedReference,
interval=timedelta(hours=2),
callback=AsyncCallback(my_callback),
),
@@ -522,5 +524,8 @@ followed by a more urgent escalation if the Dag is still
running.
* **Timezone Awareness**: Always return timezone-aware datetime objects.
* **Plugin Placement**: One convenient place for custom references is in the
plugins directory.
* **API Server Restart**: Restart the Airflow API Server after adding or
modifying custom references.
-* **Required Parameters**: Use ``required_kwargs`` to specify parameters your
reference needs.
+* **Required Parameters**: ``required_kwargs`` declares which Dag run context
values Airflow should
+ forward to ``_evaluate_with()``. Only ``dag_id`` and ``run_id`` are
available; declaring anything
+ else raises a ``ValueError`` when the deadline is evaluated. To configure a
reference itself, give
+ it constructor fields or read from an Airflow Variable.
* **Database Access**: Use the ``session`` parameter for Airflow database
queries if needed.