|
Motivation
Airflow is driven by data engineers and technology, thus tasks and results are viewed on a technical level. If something goes wrong users need to check logs in the UI. Since Airflow 3.1.0 added Human-in-the-Loop... but there is no “business user friendly” view existing. We propose improvements to add this!
The proposal is mainly about UX for users which are non-technical experts or no data engineers.
In Airflow 2.x we compensated the usability gaps via Task Instance Notes and Dag Run Notes which were displayed on the details panel. The details panel was always displayed first when clicking on a task or Dag run. We auto-generated these notes and populated them such that if a user clicked on a Task Instance a high level summary or error summary was always presented. In Airflow 3 this is not not directly possible because (1) the adding/machine generation of notes requires DB access which is undesired in the new architecture as well as (2) the notes are not displayed because per default the logs panel is displayed and the notes are hidden in a dialog where the user needs to click on a button to see them. Alongside with this (3) also logs are not scrolling to the end per default but show the start of the text per default such that the user needs to scroll down to the bottom (with incremental loading might need some clicks) in order to see details or the error. So compared to our user friendly solution (limited to 1000 chars though...) the upgrade to Airflow 3 added a usability gap.
Example of usage of the notes in Airflow 2.x
(1) Dag Summary

(2) Failure report on Task Instance

(3) KPI Summary of an execution as summary

Note that initial idea was that such capability could be provided with an extended plugin interface as initially proposed (still see mock-ups there) via AIP-68 Extended Plugin Interface for React Views. This was super-seeded with the re-implementation of the Airflow UI in 3.0 in React, plugins are possible but no generic similar function.
We propose to add an optional feature allowing to expose a good human readable Dag Run and Task Instance Summary via Markdown Templates. We envision this is a Operator or Task specific extension as opt-in, can be used and added but does not need to.
Adding capabilities to create Dag Run and Task Instance Summaries as Markdown. Similar like Dag Documentation and Task Documentation can be (statically) generated and displayed as Markdown, provide options to generate Markdown in Task Instances which are stored in the DB in order to be displayed on UI.
Compared to Notes today in Airflow 3 we propose to:

(1) Utility Methods to publish a new Summary
in class airflow.sdk.execution_time.task_runner.RuntimeTaskInstance (alongside with RuntimeTaskInstanceProtocol) the following utility methods are added:
def push_task_instance_summary(self, content: str | None) -> None: ..."""Sets and updates the current task instance summary."""def push_dag_run_summary(self, content: str | None) -> None: ..."""Sets and updates the current Dag run summary.""Once invoked in the running task execution the content is transferred via supervisor to execution API and persisted in the meta database. If None is passed any existing previous Summary is cleared.
The methods can be called during execution of a task on the worker. Similar entry to be added in async cases such that the same can be used on Triggerer as well.
(2) Additional properties to define a Markdown template file to be used
The following properties are added to the model:
airflow.sdk.definitions.dag.DAGdag_run_summary_template: str | None = None"""Optional path to a Markdown template which is processed via Jinja to be published as Dag run summary after Dag completion."""airflow.sdk.bases..operator.BaseOperatortask_instance_summary_template: str | None = None"""Optional path to a Markdown template which is processed via Jinja to be published as Task Instance summary after Dag completion."""The template files are automatically loaded on the task runner upon task completion (if provided) and using task context and XCom values passed through a Jinja templating and published. For any Task Instance on the task runner after XCom return is processed and before the runner is completed. On the completion of a Dag run similar to a on_success/on_failure hook.
With this Operators can ship and provide a default Summary template, e.g. KubernetesPodOperator can render Pod summary per default.
(3) Public API to retrieve Notes - the public API is also used from React UI to query and render the markdown.
We have many technical as well as non-technical users. Today it is hard for users to see and understand errors. We attempted to add an auto-triage to processes and tools but still users might be confused by long technical logs and it is hard to find the root cause of a problem in a long log. Some people seek for the first error message, some for the last summary. But nothing that a user can be really happy about.
With the optional Dag Run and Task Instance Summary we allow optionally per task to create a status progress as well as a human readable summary, as markdown also with links to other systems with more details and a structured, readable layout. Using Markdown we are also safe that no scripts can be injected. As an extension would also allow embedding images and folded "Details" areas to drill-into.
We want to open Airflow to more business users and make it easier to interpret technical results. So far as a summary the Notes we implemented in Airflow 2.x were a compromise to at least a short <1000 char summary with important external links. With the proposed Dag Run / Task Instance Summaries we can extend and allow customizations
Additional complexity and mental load is added to Airflow. But as it is an opt-in feature, nobody is required to use it.
Additional tables and (small) increase of meta database volume based on the summary content stored in the database.
Positive impact on non technical users of Airflow.
Additional complexity for Dag authors if the feature is implemented. But as Markdown is a standard, it is a reasonable complexity.
Database extensions would be covered by standard Alembic migration tooling. Similar like todays Notes the Summaries would be stored in an additional relation, so no additional fields needed in `dag_run` and `task_instance` tables. Selection and query only as needed via API, minimizing side effects in performance for other components.
Proposed ORM Model:

Alternative options we considered before writing this AIP:
