Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Schedule a continually airflow DAG run

Tags:

airflow

Is there a way to run airflow DAG in a loop? When trying to create a cycle (connecting the last component to the upstream of the last one) I got "Cycle detected in DAG. Faulty task: ..." Generally, I have a short flow of 3 BashOperator components which i want to run continually (without any input-output pass from the last component to the first). Thanks!

like image 786
Aviv Oron Avatar asked Dec 24 '17 08:12

Aviv Oron


People also ask

How do you run a DAG every 5 minutes?

schedule_interval is defined as a DAG arguments, and receives preferably a cron expression as a str, or a datetime. timedelta object. When following the provided link for CRON expressions it appears you can specify it as */5 * * * * to run it every 5 minutes.

Can a DAG have a loop?

Because a DAG cannot have self-loops, its adjacency matrix must have a zero diagonal, so adding I preserves the property that all matrix coefficients are 0 or 1.

What is schedule interval in Airflow?

As Airflow has its scheduler and it adopts the schedule interval syntax from cron, the smallest data and time interval in the Airflow scheduler world is minute. Inside of the scheduler, the only thing that is continuously running is the scheduler itself.


Video Answer


1 Answers

You should be able to use the TriggerDagRunOperator to rerun the DAG after the last task is finished. Just put it after the last operator and make it trigger the same DAG.

like image 95
Him Avatar answered Sep 19 '22 02:09

Him