Python 2.7.10 (default, Sep 23 2015, 19:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> from airflow.operators import SlackAPIPostOperator
>>> def on_failure_callback():
... slack_failure_notification = SlackAPIPostOperator(
... task_id='Slack_Failure_Notification',
... token='XXXX',
... channel='#airflow',
... text=":skull: - {time} - {dag} has failed".format(dag='Some Dag',
... time=datetime.now().strftime(
... "%Y-%m-%d %H:%M:%S"), ),
... owner='Failure Handler',
... )
... return slack_failure_notification.execute
...
>>> callback = on_failure_callback()
>>> callback()
The code above works in the shell. In my dag I have set on_failure_callback=callback but it does not appear that it's ever called (I would receive a Slack Notification if it did) Is there something inherently wrong with this approach or am I missing something ?
Any insight here would be appreciated.
Thanks