Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

on_failure_callback not working in airflow DAG()

I want to call two different functions for dag failure and success. For that i want to use on_failure_callback and on_success_callback in DAG() function.

As per my requirement, this callbacks should be on dag level and not task level. That's why i am writing this callbacks insiled DAG() functions while declaring dag variable.

but this callback function are not being called. Same function if i call on task level , then working fine.

This is my code:

def success():
      print("successful")
    
dag = DAG(dag_id='callback_test',schedule_interval=None,default_args=default_args,on_success_callback=success)
    
    def fun1(**kwargs):
        print("function called")
    
    task1 = PythonOperator(
        task_id='task1',
        provide_context=True,
        python_callable=fun1,
        dag=dag
        )
    
    task1
question from:https://stackoverflow.com/questions/65934476/on-failure-callback-not-working-in-airflow-dag

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

However, I think it should also work at DAG level, according to this: https://airflow.apache.org/docs/apache-airflow/1.10.10/_api/airflow/models/dag/index.html?highlight=on_failure_callback

right?

I am not being able to make it work, though :(


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...