对气流进行一般查询
是否有可能根据另一个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中运行
发布评论