You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/01/14 23:04:36 UTC

[GitHub] [airflow] ephraimbuddy commented on issue #13681: ExternalTaskSensor can never find External Parent Task

ephraimbuddy commented on issue #13681:
URL: https://github.com/apache/airflow/issues/13681#issuecomment-760531896


   The schedule_interval need to be the same for both DAGs for it to work.
   ```
   
   import datetime
   
   from airflow import DAG
   from airflow.operators.dummy import DummyOperator
   from airflow.sensors.external_task import ExternalTaskMarker, ExternalTaskSensor
   
   start_date = datetime.datetime(2015, 1, 1)
   
   with DAG(
       dag_id="example_external_task_marker_parent",
       start_date=start_date,
       schedule_interval=datetime.timedelta(minutes=30),
       tags=['example2'],
   ) as parent_dag:
       # [START howto_operator_external_task_marker]
       parent_task = ExternalTaskMarker(
           task_id="parent_task",
           external_dag_id="example_external_task_marker_child",
           external_task_id="child_task1",
       )
       # [END howto_operator_external_task_marker]
   
   with DAG(
       dag_id="example_external_task_marker_child",
       start_date=start_date,
       schedule_interval=datetime.timedelta(minutes=30),
       tags=['example2'],
   ) as child_dag:
       # [START howto_operator_external_task_sensor]
       child_task1 = ExternalTaskSensor(
           task_id="child_task1",
           external_dag_id=parent_dag.dag_id,
           external_task_id=parent_task.task_id,
           timeout=600,
           allowed_states=['success'],
           failed_states=['failed', 'skipped'],
           mode="reschedule",
       )
       # [END howto_operator_external_task_sensor]
       child_task2 = DummyOperator(task_id="child_task2")
       child_task1 >> child_task2
   ```


----------------------------------------------------------------
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:
users@infra.apache.org