gpt4 book ai didi

airflow - 我们可以在 Airflow 中为每个任务设置 priority_weight 吗?

转载 作者:行者123 更新时间:2023-12-01 13:15:52 50 4
gpt4 key购买 nike

我知道priority_weight可以设置为DAGdefault_args按照官方文档中的示例here .

我们也可以设置priority_weight DAG 中的每个任务都不同。 ?

按照教程中的示例,这意味着 t1将具有与 t2 不同的优先级.

最佳答案

Can we also set priority_weight that is different for each task in the DAG?



简答

是的

长版

你在这里显得有些困惑。在给定链接中引用 passage above the snippet :

..we have the choice to explicitly pass a set of arguments to each task’s constructor (which would become redundant), or (better!) we can define a dictionary of default parameters that we can use when creating tasks..



所以现在你一定已经推断出在 priority_weight 中传递的 default_args 实际上是针对单个 task s 而不是 DAG 本身。当然,查看代码很明显它是 parameter of BaseOperator not DAG SQLAlchemy 模型

此外,一旦您了解了上述事实,您很快就会意识到 task 的每个 DAG 分配相同的优先级并没有多大意义。官方文档中的上述示例似乎确实忽略了这个简单的推理(除非我遗漏了一些东西)。然而 docstring 似乎确实表明了这一点

:param priority_weight: priority weight of this task against other task.
This allows the executor to trigger higher priority tasks before
others when things get backed up.


UPDATE-1

正如 pointed out 在评论中正确的 @Alessandro S. 一样,将相同的 priority_weight 分配给 DAG 中的所有任务毕竟不是不合理的,因为 priority_weight 不是在 DAG 级别强制执行,而是在 pool 级别
  • 因此,当您将 2 个(或更多)dag 放入图片(都访问相同的外部资源)时,一个有效的用例可能是您希望将一个 dag 的所有任务提升到另一个
  • 为了实现这一点,第一个 dag 的所有任务可以是 priority_weight 的单个值,该值高于第二个 dag 中的任务的值。
  • 关于airflow - 我们可以在 Airflow 中为每个任务设置 priority_weight 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55145641/

    50 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com