调度dag在Airflow中运行

编程入门 行业动态 更新时间:2024-10-18 20:21:47
本文介绍了调度dag在Airflow中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

对气流进行一般查询

是否有可能根据另一个dag文件的时间表来安排dag文件。

Is it possible to have a dag file scheduled based on another dag file's schedule.

例如,如果我有2个dag,即dag1和dag2。我试图查看是否每次dag1成功时都可以运行dag2,否则dag2不运行。气流中有可能吗?

For example, if I have 2 dags namely dag1 and dag2. I am trying to see if I can have dag2 run each time dag1 is successful else dag2 does not run. Is this possible in Airflow.

推荐答案

您将要添加 TriggerDagRunOperator dag1 的结尾,并将时间表设置为 dag2 到 None 。

You will want to add a TriggerDagRunOperator the end of dag1 and set the schedule of dag2 to None.

此外,如果要处理 dag1 输出的多个案例,您可以添加 BranchPythonOperator 可以根据其输出创建多个路径。例如,您可以将其设置为在成功时执行TriggerDagRunOperator或让您警告!DAG1中的任务失败!松弛。如果出现错误,请使用 SlackAPIPostOperator 抛出(或您要构建的任何其他逻辑)。

In addition, if you want to handle multiple cases for the output of dag1, you can add in a BranchPythonOperator to create multiple paths based on its output. For example, you could set it to either execute the TriggerDagRunOperator on success or Slack you "Warning! Task Failure in DAG1!" with the SlackAPIPostOperator if an error is thrown (or any other logic you want to build in).

如果您不关心多个结果,也可以使用 ShortCircuitOperator 来防止它基于 dag1 输出。

If you don't care about multiple outcomes, you could also just use the ShortCircuitOperator before the TriggerDagRunOperator to prevent it from running based on the dag1 output.

更多推荐

调度dag在Airflow中运行

本文发布于:2023-07-07 22:13:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1068489.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:dag   Airflow

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!