Mahdi Sadeghi
Mahdi Sadeghi

Reputation: 733

How to pass parameters to scheduled task in Airflow?

I need a scheduled task in airflow to run with different parameters. One way would be to write different dags for different parameters, but i was wondering if there is a better way of doing this like how we pass parameters to manual trigger.

Upvotes: 0

Views: 2518

Answers (1)

bruno-uy
bruno-uy

Reputation: 1875

The bigger issue with writing the same DAG with different URLs is that you're breaking the DRY (Don't Repeat Yourself) principle. If you need different schedules and you don't want to repeat the code twice, you can take this DAG factory idea and build your own factory for these two DAGs. You'll finally have two DAG files that invokes the same factory with the parameters of schedule (1 AM and 2 AM) and URL.

Upvotes: 2

Related Questions