You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: airflow-core/docs/core-concepts/params.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ If the user-supplied values don't pass validation, Airflow shows a warning inste
32
32
DAG-level Params
33
33
----------------
34
34
35
-
To add Params to a :class:`~airflow.models.dag.DAG`, initialize it with the ``params`` kwarg.
35
+
To add Params to a :class:`~airflow.sdk.DAG`, initialize it with the ``params`` kwarg.
36
36
Use a dictionary that maps Param names to either a :class:`~airflow.sdk.definitions.param.Param` or an object indicating the parameter's default value.
Copy file name to clipboardExpand all lines: airflow-core/docs/core-concepts/xcoms.rst
+31-2Lines changed: 31 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,11 @@ XComs (short for "cross-communications") are a mechanism that let :doc:`tasks` t
25
25
26
26
An XCom is identified by a ``key`` (essentially its name), as well as the ``task_id`` and ``dag_id`` it came from. They can have any serializable value (including objects that are decorated with ``@dataclass`` or ``@attr.define``, see :ref:`TaskFlow arguments <concepts:arbitrary-arguments>`:), but they are only designed for small amounts of data; do not use them to pass around large values, like dataframes.
27
27
28
+
.. versionchanged:: 3.0
29
+
30
+
In Airflow 3.0+, XCom operations should be performed through the Task Context using
31
+
:func:`~airflow.sdk.get_current_context`. Direct database access is not possible.
32
+
28
33
XComs are explicitly "pushed" and "pulled" to/from their storage using the ``xcom_push`` and ``xcom_pull`` methods on Task Instances.
29
34
30
35
To push a value within a task called **"task-1"** that will be used by another task:
@@ -73,8 +78,27 @@ An example of pushing multiple XComs and pulling them individually:
73
78
# Pulling entire xcom data from push_multiple task
74
79
data = context["ti"].xcom_pull(task_ids="push_multiple", key="return_value")
75
80
81
+
.. versionchanged:: 3.0
82
+
83
+
In Airflow 3.0+, you can also use the Task Context directly for XCom operations:
84
+
85
+
.. code-block:: python
86
+
87
+
from airflow.sdk import get_current_context
76
88
77
89
90
+
@task
91
+
defexample_task():
92
+
context = get_current_context()
93
+
ti = context["ti"]
94
+
95
+
# Push XCom
96
+
ti.xcom_push(key="my_key", value="my_value")
97
+
98
+
# Pull XCom
99
+
value = ti.xcom_pull(task_ids="previous_task", key="my_key")
100
+
return value
101
+
78
102
.. note::
79
103
80
104
If the first task run is not succeeded then on every retry task XComs will be cleared to make the task run idempotent.
@@ -91,7 +115,12 @@ Custom XCom Backends
91
115
92
116
The XCom system has interchangeable backends, and you can set which backend is being used via the ``xcom_backend`` configuration option.
93
117
94
-
If you want to implement your own backend, you should subclass :class:`~airflow.models.xcom.BaseXCom`, and override the ``serialize_value`` and ``deserialize_value`` methods.
118
+
If you want to implement your own backend, you should subclass :class:`~airflow.sdk.execution_time.xcom.XCom`, and override the ``serialize_value`` and ``deserialize_value`` methods.
119
+
120
+
.. versionchanged:: 3.0
121
+
122
+
The base class for custom XCom backends is now :class:`~airflow.sdk.execution_time.xcom.XCom`
123
+
from the airflow.sdk namespace.
95
124
96
125
You can override the ``purge`` method in the ``BaseXCom`` class to have control over purging the xcom data from the custom backend. This will be called as part of ``delete``.
97
126
@@ -104,6 +133,6 @@ If you can exec into a terminal in an Airflow container, you can then print out
0 commit comments