This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v2-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v2-10-test by this push:
     new 37c25f96c4f [v2-10-test] update xcom docs  (#46284) (#47068)
37c25f96c4f is described below

commit 37c25f96c4f42e76ca425857afb555543ad5b942
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Feb 25 23:21:00 2025 +0100

    [v2-10-test] update xcom docs  (#46284) (#47068)
    
    * update xcom docs
    
    * add example
    
    * add example
    
    * add multiple_outputs=True
    
    * use taskflow
    (cherry picked from commit 1648d7ef61f478522cd975f0209ddca47e14568f)
    
    Co-authored-by: Kalyan R <[email protected]>
---
 docs/apache-airflow/core-concepts/xcoms.rst | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/docs/apache-airflow/core-concepts/xcoms.rst 
b/docs/apache-airflow/core-concepts/xcoms.rst
index fad9420cea6..d49d9b0e591 100644
--- a/docs/apache-airflow/core-concepts/xcoms.rst
+++ b/docs/apache-airflow/core-concepts/xcoms.rst
@@ -52,7 +52,28 @@ You can also use XComs in :ref:`templates 
<concepts:jinja-templating>`::
 
 XComs are a relative of :doc:`variables`, with the main difference being that 
XComs are per-task-instance and designed for communication within a DAG run, 
while Variables are global and designed for overall configuration and value 
sharing.
 
-If you want to push multiple XComs at once or rename the pushed XCom key, you 
can use set ``do_xcom_push`` and ``multiple_outputs`` arguments to ``True``, 
and then return a dictionary of values.
+If you want to push multiple XComs at once you can set ``do_xcom_push`` and 
``multiple_outputs`` arguments to ``True``, and then return a dictionary of 
values.
+
+An example of pushing multiple XComs and pulling them individually:
+
+.. code-block:: python
+
+    # A task returning a dictionary
+    @task(do_xcom_push=True, multiple_outputs=True)
+    def push_multiple(**context):
+        return {"key1": "value1", "key2": "value2"}
+
+
+    @task
+    def xcom_pull_with_multiple_outputs(**context):
+        # Pulling a specific key from the multiple outputs
+        key1 = context["ti"].xcom_pull(task_ids="push_multiple", key="key1")  
# to pull key1
+        key2 = context["ti"].xcom_pull(task_ids="push_multiple", key="key2")  
# to pull key2
+
+        # Pulling entire xcom data from push_multiple task
+        data = context["ti"].xcom_pull(task_ids="push_multiple", 
key="return_value")
+
+
 
 .. note::
 

Reply via email to