简体   繁体   English

使用 Airflow 中的另一个 dag 触发外部 dag

[英]Triggering the external dag using another dag in Airflow

Having list of tasks which calls different dags in master dag.I'm using the TriggerDagrunoperator to accomplish this.拥有在主 dag 中调用不同 dag 的任务列表。我正在使用 TriggerDagrunoperator 来完成此任务。 But facing few issues.但面临的问题很少。

  • TriggerDagrunoperator doesn't wait for completion of external dag, it triggers next task. TriggerDagrunoperator 不会等待外部 dag 的完成,它会触发下一个任务。 I want that to wait until completion and next task should trigger based on the status.我希望它等到完成,下一个任务应该根据状态触发。 Came across ExternalTaskSensor.遇到了 ExternalTask​​Sensor。 It is making the process complicated.它使过程变得复杂。 Is there any other solution to fix this?有没有其他解决方案来解决这个问题?

  • If I trigger the master dag again, I want the task to restart from where it is failed.如果我再次触发 master dag,我希望任务从失败的地方重新启动。 Right now, it's not restarting, but for time based schedule,it will.现在,它不会重新启动,但对于基于时间的计划,它会。

.. I want that to wait until completion .. Came across ExternalTaskSensor. ..我希望那等到完成..出现在ExternalTask​​Sensor上。 It is making the process complicated .. 这使过程变得复杂..

I'm unaware of any other way to achieve this. 我不知道有任何其他方法可以实现这一目标。 I myself did this the same way . 我自己也这样


If I trigger the master dag again, I want the task to restart from where it is failed... 如果我再次触发master dag,我希望任务从失败的地方重新启动...

This requirement of your goes against the principle of idempotency that Airflow demands. 您的这一要求违背了Airflow要求的幂等原则 I'd suggest you try to re-work you jobs in incorporate idempotency (for instance in case of retries, you have to have idempotency). 我建议您尝试重新处理包含幂等性的工作(例如,在重试的情况下,您必须具有幂等性)。 Meanwhile you can take inspiration from some people and try to achieve something similar (but it will be pretty complicated) 同时,您可以从某些人那里获得启发,并尝试实现类似的目标(但这会非常复杂)

With Airflow 2.0.1, the triggering dag can be made to wait for completion of target dag with parameter wait_for_completion使用 Airflow 2.0.1,可以使用参数wait_for_completion使触发 dag 等待目标 dag 完成

ref: here参考: 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM