snehlata08 opened a new issue #14580:
URL: https://github.com/apache/airflow/issues/14580


   I need a sub process kind of thing for multiple dags. 
   I know we can call a child dag from parent dag through TriggerDagRunOperator 
but in that process how can we notify the parent if the child dag has run 
successfully or not. 
   Basically what i am looking at is something like the  [BPMN 
tool](https://flowable.com/open-source/docs/bpmn/ch07b-BPMN-Constructs/#sub-processes-and-call-activities)
 . I also understand that basically this is a data workflow but something like 
this is required so that we know at what stage is the dag running. 
   
   This is my parent dag. 
   
   ```
   import airflow
   from airflow.models import DAG
   from airflow.operators.trigger_dagrun import TriggerDagRunOperator
   
   dag = DAG(
       dag_id='parent',
       default_args={'start_date': airflow.utils.dates.days_ago(2), 'owner': 
'airflow'},
       schedule_interval='@once',
   )
   
   def trigger(context, dag_run_obj):
       dag_run_obj.payload = {'message': context['params']['message']}
       return dag_run_obj
   
   test_trigger_dagrun = TriggerDagRunOperator(
       dag=dag,
       task_id='test_trigger_dagrun',
       trigger_dag_id="child",
       conf={'message': 'Hello World'}
   )
   ```
   
   This is child dag 
   ``` 
   import airflow
   from airflow.models import DAG
   from airflow.operators.python import PythonOperator
   
   dag = DAG(
       dag_id='child',
       default_args={'start_date': airflow.utils.dates.days_ago(2), 'owner': 
'airflow'},
       schedule_interval=None,
   )
   
   def run_this_func(*args, **kwargs):
       print("Remotely received a message: {}".
             format(kwargs['dag_run'].conf.get('message')))
   
   run_this = PythonOperator(
       task_id='run_this',
       python_callable=run_this_func,
       provide_context=True,
       dag=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.

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


Reply via email to