Apache Airflow - trigger/schedule DAG rerun on completion (File Sensor)

后端 未结 2 1793
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-04 13:50

Good Morning.

I\'m trying to setup a DAG too

  1. Watch/sense for a file to hit a network folder
  2. Process the file
  3. Archive the file
2条回答
  •  隐瞒了意图╮
    2021-02-04 14:38

    Set schedule_interval=None and use airflow trigger_dag command from BashOperator to launch next execution at the completion of the previous one.

    trigger_next = BashOperator(task_id="trigger_next", 
               bash_command="airflow trigger_dag 'your_dag_id'", dag=dag)
    
    sensor_task >> proccess_task >> archive_task >> trigger_next
    

    You can start your first run manually with the same airflow trigger_dag command and then trigger_next task will automatically trigger the next one. We use this in production for many months now and and it runs perfectly.

提交回复
热议问题