This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new ce6ac41764 Displaying "actual" try number in TaskInstance view (#34635)
ce6ac41764 is described below
commit ce6ac4176445efbd6097cdcdb10782752a4f1bf9
Author: Sam Wheating <[email protected]>
AuthorDate: Wed Jan 31 06:47:35 2024 -0800
Displaying "actual" try number in TaskInstance view (#34635)
---
airflow/models/taskinstance.py | 12 ++++++++++++
airflow/www/views.py | 6 ++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index aecb03dc2e..38b787cbe8 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -1433,6 +1433,18 @@ class TaskInstance(Base, LoggingMixin):
"""
return _get_try_number(task_instance=self)
+ @try_number.expression
+ def try_number(cls):
+ """
+ This is what will be used by SQLAlchemy when filtering on try_number.
+
+ This is required because the override in the get_try_number function
causes
+ try_number values to be off by one when listing tasks in the UI.
+
+ :meta private:
+ """
+ return cls._try_number
+
@try_number.setter
def try_number(self, value: int) -> None:
"""
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 783a904e2d..0b7ede98dd 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -5476,7 +5476,7 @@ class TaskInstanceModelView(AirflowModelView):
"priority_weight",
"queue",
"queued_dttm",
- "try_number",
+ "prev_attempted_tries",
"pool",
"queued_by_job_id",
"external_executor_id",
@@ -5505,9 +5505,7 @@ class TaskInstanceModelView(AirflowModelView):
"queued_by_job_id",
]
- label_columns = {
- "dag_run.execution_date": "Logical Date",
- }
+ label_columns = {"dag_run.execution_date": "Logical Date",
"prev_attempted_tries": "Try Number"}
search_columns = [
"state",