Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Airflow DAG success callback

Is there an elegant way to define callback for DAG succeed event? I really don't want to set a task which will be upstream of all other tasks with on_sucess_callback.

Thanks!

like image 985
Aviv Oron Avatar asked Jan 09 '18 08:01

Aviv Oron


2 Answers

So if I understand correctly, the last step of your DAG is, in case of success, to call back to some other system. So I would encourage you to model your DAG exactly that way.

Why would you try to hide that part from the logic of your DAG? That's exactly what the up/downstream modeling is for. Hiding part of the DAG logic for the sake of the graph's aesthetics sounds like a bad tradeoff to me.

I would discourage you to set the callback task as downstream to all tasks, it should be downstream only to final tasks in the DAG.

like image 107
benjamin Avatar answered Nov 13 '22 23:11

benjamin


Don't know how much it helps you now, but the functionality you are looking for exists in Airflow 1.10... a DAG has an on_success_callback

https://airflow.apache.org/code.html#airflow.models.DAG

like image 22
user3027497 Avatar answered Nov 13 '22 23:11

user3027497