apache / airflow

Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
https://airflow.apache.org/
Apache License 2.0
37.19k stars 14.32k forks source link

Indicate warnings or other "non-failing" indicators in Airflow UI and callbacks #42757

Open matthewblock opened 1 month ago

matthewblock commented 1 month ago

Description

Sometimes a task shouldn't fail but could contain a warning that the user should know about and fix; for example, a deprecation warning or a user-logged warning. These warnings don't "bubble up" anywhere in the Airflow UI.

Making warnings more visible could have the impact of making upgrades (like the upcoming 3.0 upgrade) much easier for developers.

Possible but not optimal current solutions:

A solution could look like all otherwise successful task instances in a DAG run labeled by a yellow (or other color) dot instead of a green dot. It could also help to aggregate warning-level or error-level messages in the UI.

Implementation wise - Maybe there could be a separate task instance state (warning) or different UI indicator on the current success state that could be leveraged to visually indicate this situation. If it were a separate warning state, an on_warning_callback could also be added to send more information to the user's existing Slack alert workflow.

Use case/motivation

Better indication that something in a task went wrong, or something happened the user should be notified about

Related issues

@RNHTTR recommend I copy here from this discussion:

https://github.com/apache/airflow/discussions/42188

Are you willing to submit a PR?

Code of Conduct

matthewblock commented 1 month ago

Some more thoughts:

I'm realizing that for a TaskInstance, both success and failed states can have warnings, where a warning is at least one call of warning.warn() during task execution. Maybe a TaskInstance should have an additional attribute has_warnings if any warnings were issued during its execution.

We can collect any warnings during task execution using the Python built in warnings.catch_warnings context manager, at least when using PythonOperator and similar. We could then set ti.has_warnings and handle these warnings in an on_warning_callback, or even aggregated somewhere else in the UI.

This would be useful to help developers stay on top of Airflow-communicated deprecation warnings and avoid unpleasant surprises when upgrading.

Is there a better alternative to see all deprecation warnings across all DAGs/tasks that currently exists?