ashb commented on code in PR #52297:
URL: https://github.com/apache/airflow/pull/52297#discussion_r2179528939
##########
airflow-core/docs/core-concepts/xcoms.rst:
##########
@@ -73,7 +76,24 @@ An example of pushing multiple XComs and pulling them
individually:
# Pulling entire xcom data from push_multiple task
data = context["ti"].xcom_pull(task_ids="push_multiple",
key="return_value")
+You can also use the Task Context directly for XCom operations:
+
+.. code-block:: python
+ from airflow.sdk import get_current_context
+
+
+ @task
+ def example_task():
+ context = get_current_context()
+ ti = context["ti"]
+
+ # Push XCom
+ ti.xcom_push(key="my_key", value="my_value")
+
+ # Pull XCom
+ value = ti.xcom_pull(task_ids="previous_task", key="my_key")
+ return value
Review Comment:
Its also slightly odd to push a value and return the same value
--
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]