Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can we parameterize the airflow schedule_interval dynamically reading from the variables instead of passing as the cron expression

can we parameterize the airflow schedule_interval dynamically reading from the airflow variables instead of passing directly as the cron expression

I have passed the following way as per airflow documentation args = { 'owner': 'pavan', 'depends_on_past': False, 'start_date': datetime(2020, 1, 15), 'email_on_failure': True, 'email_on_retry': False, 'retries': 0, 'on_failure_callback': notify_email }

with DAG(dag_id=DAG_NAME, default_args=args, schedule_interval='* 1 * * *', catchup=False) as dag:

like image 494
pavan Avatar asked Oct 27 '25 14:10

pavan


1 Answers

Yes

Technically you can do it, but it brings 2 problems

  • minor problem: reading a Variable means a SQL-query being fired to Airflow's SQLAlchemy backend meta-db. And doing it in your DAG-definition script means this will happen as the DAG is continuously parsed by Airflow in background. Read point 2 here

  • major problem: A Variable can be edited via UI. But altering an Airflow DAG's schedule_interval can have wierd behaviours and may require you to either rename the DAG or (anecdotal finding) restart the scheduler to fix that

like image 103
y2k-shubham Avatar answered Oct 30 '25 14:10

y2k-shubham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!