tirkarthi commented on issue #62988:
URL: https://github.com/apache/airflow/issues/62988#issuecomment-4016907165

   Agree with @jroachgolf84  that this could be a documentation improvement. 
Following dag works as expected.
   
   ```python
   from __future__ import annotations
   
   from airflow.providers.standard.operators.python import get_current_context
   from airflow.providers.standard.operators.trigger_dagrun import 
TriggerDagRunOperator
   from airflow.sdk import dag, task
   
   
   @dag()
   def gh62988_child_dag():
       @task
       def run():
           return "hello world"
   
       run()
   
   
   @dag()
   def gh62988_top_dag():
       @task
       def postprocess(trigger_task):
           context = get_current_context()
           print(context["task_instance"])
           child_run_id = 
context["task_instance"].xcom_pull(task_ids="trigger_dag", key="trigger_run_id")
           print(f"{child_run_id = }")
           child_dag_return_value = context["task_instance"].xcom_pull(
               dag_id="gh62988_child_dag", task_ids="run", run_id=child_run_id
           )
           print(f"{child_dag_return_value = }")
           if not child_dag_return_value == "hello world":
               raise ValueError(f"child dag return_value 
{child_dag_return_value}")
   
       t_trigger = TriggerDagRunOperator(
           task_id="trigger_dag", trigger_dag_id="gh62988_child_dag", 
wait_for_completion=True
       )
       postprocess(t_trigger.output)
   
   
   gh62988_top_dag()
   gh62988_child_dag()
   ```


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