ephraimbuddy commented on issue #16983:
URL: https://github.com/apache/airflow/issues/16983#issuecomment-882043796
The `on_failure_callback` is a task argument and not DAG level argument.
The correct dag is:
```
import sys
from datetime import datetime
from airflow import DAG
from airflow.models import Variable
from airflow.operators.python_operator import PythonOperator
def on_failure(ctx):
print('hello world')
print(ctx)
def always_fails():
sys.exit(1)
dag = DAG(
dag_id='always_fails',
description='dag that always fails',
schedule_interval=None,
catchup=False,
start_date=datetime(2021,7,12),
)
task = PythonOperator(task_id='test-error-notifier',
python_callable=always_fails,on_failure_callback=on_failure, dag=dag)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]