Search code examples
pythongoogle-cloud-platformairflowdirected-acyclic-graphsgoogle-cloud-composer

Is It possible to trigger a Dag from an on_failure_callback?


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"


Solution

  • 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
        )