Reputation: 2570
I have an airflow DAG that looks like this
(A1 -> B1) -> C1 -> D1
(A2 -> B2) -> C2 -> D2
(A3 -> B3) -> C3 -> D3
The problem is:
A
always succeeds (it kicks off a get API request)B
may fail (polls the API every 30 seconds until complete).A
if B
fails.What is the best way to do that?
I tried branching back to A, e.g.
A >> B >> branch >> C >> D
branch >> if_failed >> A
But I get the error Cycle detected in DAG
Upvotes: 0
Views: 200
Reputation: 1156
There are multiple parts of this question that we should consider:
A. You can create a custom operator that upon execute()
calls A
first and then B
.
B. You can create a PythonOperator instance and use Airflow hooks or pure python code to get the job done.
Upvotes: 2
Reputation: 346
DAG is for "Directed Acyclic Graph", the important part is "Acyclic", you can't perform a cycle, your only option is to relaunch DAG when it fails. Or only one task if you can isolate it and made it idempotent.
This answer may help you
Upvotes: 1