正如标题所暗示的,希望了解 dag 定义中的 catchup = False 和最新的 only 运算符之间的区别。
https://airflow.apache.org/docs/stable/scheduler.html https://airflow.apache.org/docs/stable/scheduler.html
https://airflow.apache.org/docs/stable/_modules/airflow/operators/latest_only_operator.html https://airflow.apache.org/docs/stable/_modules/airflow/operators/latest_only_operator.html
嗯,我想说,它们是完全不同的概念,它们可以独立使用。确实,它们都可以用来防止回填,但如果这是您唯一关心的问题,那么只需使用catchup=False
。引用自这个回复 http://codeha.us/apache-airflow-development/msg03853.html事实上,由一位 Airflow 开发人员提出,似乎很明显,好的做法是使用:
作为LatestOnlyOperator的作者,目标是作为权宜之计,直到
catchup=错误着陆。
但他接着说LatestOnlyOperator
应该被弃用。我不同意(作为两者的用户catchup=False
and LatestOnlyOperator
)我会尽力解释。我对这两个概念的直觉是这样的:
追赶=真实
在 DAG 定义中(即当您指定其default_args
)你可以设置标志catchup
to True
。如果您将此标志设置为True
并且您将 DAG 设置为 ON,然后调度程序将为每个调度间隔创建 DAG 运行start_date
到“现在”并将按顺序执行它们。引用文档 https://airflow.apache.org/docs/stable/scheduler.html#backfill-and-catchup:
If the dag.catchup
值曾经是True
相反,调度程序将为 2015 年 12 月 1 日到 2016 年 1 月 2 日之间的每个已完成的时间间隔创建一次 DAG 运行(但尚未为 2016 年 1 月 2 日创建一次 DAG 运行,因为该时间间隔尚未完成),并且调度程序将按顺序执行它们。
最新唯一运营商
A LatestOnlyOperator
是一个延伸BaseOperator
。如果 DAG 运行不在最晚计划间隔(即“最后一次运行”)。还引述自LatestOnlyOperator
文档字符串:
"""
Allows a workflow to skip tasks that are not running during the most
recent schedule interval.
If the task is run outside of the latest schedule interval, all
directly downstream tasks will be skipped.
Note that downstream tasks are never skipped if the given DAG_Run is
marked as externally triggered.
"""
结论
您可以使用以下命令定义计划的 DAGcatchup=True
并使用LatestOnlyOperator
以确保在追赶运行期间不会执行某些任务。而且LatestOnlyOperator
如果您想要重新运行一些过去的 DAG 运行(例如通过在 UI 中清除它们),但您希望在重新运行期间跳过一些任务(例如发送的通知),则可以使用此选项。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)