Dynamic schedule_interval in Airflow

北城余情 提交于 2021-02-08 07:21:02

问题


I try to run a dynamic schedule_interval in Airflow like below. But it works only when I run the dag manually. Could you please help me say, if the dynamic schedule_interval could be a reason, why the dag does not run automatically or is there any other reasons for that?

if datetime.today().day == 1:
    schedule_interval = '00 07 * * *'
else:
    schedule_interval = '00 07 * * 1'

Thank you!


回答1:


You shouldn't set the schedule_interval to be dynamic like this as it can lead to unexpected results (as you're seeing).

It looks like you're trying to run the DAG only on Mondays is that right? If that is the case then all you need to do is set the schedule_interval to 00 07 * * 1, you don't need the if condition.



来源:https://stackoverflow.com/questions/59355145/dynamic-schedule-interval-in-airflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!