hterik opened a new issue, #62988:
URL: https://github.com/apache/airflow/issues/62988

   ### Description
   
   When triggering a dag through `TriggerDagRunOperator`, it would be useful 
for the dag that initiated the trigger to fetch information produced in the 
triggered dag .
   
   Example:
   ```python
   @dag()
   def child_dag():
       @task
       def run():
           return "hello world"
       run()
   
   @dag()
   def top_dag():
       @task
       def postprocess(trigger_task):
           context = get_current_context()
           child_run_id = 
context["task_instance"].xcom_pull(task_ids="trigger_child", 
key="trigger_run_id")
           child_dag_return_value = context["task_instance"].xcom_pull(
               dag_id="child_dag",
               task_id="run",
               DESIRED_PARAMETER_TO_SET_RUN_ID=child_run_id       # 
<---------------------------------------
           )
           assert child_dag_return_value == "hello world"
   
   
       t_trigger = TriggerDagRunOperator(
           task_id="trigger_child",
           trigger_dag_id="child_dag",
           wait_for_completion=True
       )
       postprocess(t_trigger)
   ```
   
   While `xcom_pull` does allow fetching from a different `dag_id`, it has no 
parameter to control the exact `run_id`, it assumes the `execution_date` is the 
same, or with `include_prior_dates=True` it takes the latest found. (In the 
example above this doesn't make any difference because the return value is 
static, in more realistic scenarios, the output is based on parameters passed 
from the top_dag and need to be in sync)
   
   ### Use case/motivation
   
   _No response_
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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

Reply via email to