Is It possible to trigger a Dag from an on_failure_callback?

Question:

I would like to trigger a Dag when a task is failed. I want to use the "on_failure_callback", however, I have not found information about it.

Do you know if it is possible to trigger the dag from the "on_failure_callback"?

In the past, I have used the TriggerDagRunOperator to trigger drags form other dags, however, I want to do it form the "on_failure_callback"

Asked By: Dylan García

||

Answers:

You can create a task TriggerDagRunOperator with trigger rule all_failed or one_failed acvording your flow.

Answered By: ozs

I created a python function like the following one. This function solves the problem.

def test(context):
    c = Client(None,None)
    c.trigger_dag(dag_id='name_of_the_dag', conf={})

t2 = DummyOperator(
    task_id="prueba",
    on_success_callback=test
    )
Answered By: Dylan García