Skip to content
Advertisement

Airflow- how to send out email alert when sensor is set to soft fail

In the dag below, sensor A is set to soft_fail = True, because I’d like to skip B and C if A fails. The problem is I’d still like to get an email alert when A fails. But when soft_fail is true, A is marked as success when the sensor doesn’t detect anything, and no email alert would be sent out. Could someone please help to point out how to achieve this? Many thanks.

A (sensor, soft_fail = True) >> B >> C

Advertisement

Answer

Airflow sensor is marked as skipped (not success) when it fails and soft_fail is True.

There is no option to add email on skip not a callback. But you can create a new task from the operator EmailOperator, which run when the sensor A is marked as skipped. Unfortunately, there is no trigger rule to run a task when upstream is skipped, but you can create a new operator which check the state of A and send the email based on it.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement