At first working with dag callback
(on_failure_callback
and on_success_callback
), I thought it would trigger the success
or fail
statuses when the dag
finishes (as it is defined in dag).
But then it seems to be instanciated at every task instance
and not dag run
, so if a DAG has N tasks, it will trigger these callbacks N times.
I'm trying to catch the task-id and so send to slack. Reading another related question I came up with the below:
def success_msg(context):
slack.slack_message(context['task_instance']); #send task-id to slack
def failure_msg(context):
slack.slack_message(context['task_instance']); #send task-id to slack
default_args = {
[...]
'on_failure_callback': failure_msg,
'on_success_callback': success_msg,
[...]
}
But it fails, how should I parse the context variables and so be allowed to get the task-id?