Airflow 中的动态 schedule_interval [英] Dynamic schedule_interval in Airflow

查看:124
本文介绍了Airflow 中的动态 schedule_interval的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 Airflow 中运行动态 schedule_interval,如下所示.但它仅在我手动运行 dag 时才有效.你能帮我说一下,如果动态 schedule_interval 可能是一个原因,为什么 dag 没有自动运行或者还有其他原因吗?

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'

谢谢!

推荐答案

您不应该像这样将 schedule_interval 设置为动态的,因为它会导致意外结果(如您所见).

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

您似乎只想在星期一运行 DAG,对吗?如果是这种情况,那么您需要做的就是将 schedule_interval 设置为 00 07 * * 1,您不需要 if条件.

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.

这篇关于Airflow 中的动态 schedule_interval的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆