josh-fell commented on pull request #16624:
URL: https://github.com/apache/airflow/pull/16624#issuecomment-867725810


   This change enforces the proper dependency between a task that writes an 
`XCom` and one that consumes the same `XCom`.
   
   ```python
   write_xcom = KubernetesPodOperator(
           namespace="default",
           image="alpine",
           cmds=[
               "sh",
               "-c",
               "mkdir -p /airflow/xcom/;echo '[1,2,3,4]' > 
/airflow/xcom/return.json",
           ],
           name="write-xcom",
           do_xcom_push=True,
           is_delete_operator_pod=True,
           in_cluster=True,
           task_id="write-xcom",
           get_logs=True,
       )
   
       pod_task_xcom_result = BashOperator(
           bash_command="echo \"{{ task_instance.xcom_pull('write-xcom')[0] 
}}\"",
           task_id="pod_task_xcom_result",
       )
   ```
   As written currently both of these tasks execute in parallel.  
   
![image](https://user-images.githubusercontent.com/48934154/123288428-91911f00-d4dd-11eb-9957-b18450003fbc.png)
   
   But the should execute sequentially.
   
![image](https://user-images.githubusercontent.com/48934154/123288358-7de5b880-d4dd-11eb-9d0c-eda1ac4fee3e.png)
   
   This dependency would be handled by converting the `xcom_pull` in the 
"pod_task_xcom_result" task to use the Taskflow API but accessing specific 
values from an operator `.output` is not supported yet (see #16618).  Yes, this 
is an example but the functional dependencies should be correct for users to 
reference.


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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to