Can a failed Airflow DAG Task Retry with changed parameter

徘徊边缘 提交于 2019-12-02 09:40:42

First of all: that's an excellent question, I wonder why it hasn't been discussed widely until now


I can think of two possible approaches

  1. Fusing Operators: As pointed out by @Kris, Combining Operators together appears to be the most obvious workaround

  2. Separate Top-Level DAGs: Read below


Separate Top-Level DAGs approach

Given

  • Say you have tasks A & B
  • A is upstream to B
  • You want execution to resume (retry) from A if B fails

(Possibile) Idea: If your'e feeling adventurous

  • Put tasks A & B in separate top-level DAGs, say DAG-A & DAG-B
  • At the end of DAG-A, trigger DAG-B using TriggerDagRunOperator
    • In all likelihood, you will also have to use an ExternalTaskSensor after TriggerDagRunOperator
  • In DAG-B, put a BranchPythonOperator after Task-B with trigger_rule=all_done
  • This BranchPythonOperator should branch out to another TriggerDagRunOperator that then invokes DAG-A (again!)

Useful references


EDIT-1

Here's a much simpler way that can achieve similar behaviour

How can you re-run upstream task if a downstream task fails in Airflow (using Sub Dags)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!