Nikhil Suthar
Nikhil Suthar

Reputation: 2431

How to implement the one_done trigger rule for Airflow?

Airflow provides multiple trigger rules except for the one_done trigger.

Is there any way, we can implement the one_done trigger in airflow?

I need the one_done trigger rule for the below case:

Let's suppose I have the below tasks dependencies,

A >>[B,C,D,E]>>F

Task F need to be triggered as soon as any of tasks B or C or D or E get completed irrespective of the status of failed or success.

Upvotes: 2

Views: 599

Answers (2)

Elad Kalif
Elad Kalif

Reputation: 16109

Starting Airflow 2.5.0 a new trigger rule one_done was added (see PR, feature request) This new trigger rule handles your use case without any workarounds.

Upvotes: 1

Hussein Awala
Hussein Awala

Reputation: 5110

I think you can do a trick by adding two dummy tasks before F, one with the trigger rule one_success and the second with the trigger rule one_failed, and for F, you should use one_success:


A >> [B,C,D,E]
[B,C,D,E] >> Dummy1
[B,C,D,E] >> Dummy2
[Dummy1, Dummy2] >> F

When a task finish:

  • if its state is success, Dummy1 will be executed and marked as success
  • if its state is failed, Dummy2 will be executed and marked as success

In the two cases, F will be executed

Upvotes: 0

Related Questions