SlackNotifier works fine when called directly from the callback however is not doing anything once I call it from within a defined callback function (need to execute it only when DAG is not triggered manually). The function itself works fine (e.g. logging works). Any ideas why pls?
I have tried to use send_slack_notification() with same results. What works is SlackWebhookOperator() however that would require considerable changes (fails with multiple ERRORs right now)
def dag_run_info(**context):
dag_run = context['dag_run']
run_type = dag_run.run_type
return run_type
def on_failure_callback(context):
run_type = context['task_instance'].xcom_pull(task_ids='get_dag_run_info')
if run_type == 'manual':
return SlackNotifier(slack_conn_id=SLACK_CONNECTION_ID, text=SLACK_MESSAGE, channel=SLACK_CHANNEL)
else:
logging.info(f'No Slack notification for failed DAG because run_type:{run_type}')
New contributor
Tomáš Trúchly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1