This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v2-8-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 9f21c32f9a3891995373c07c5644068d22ce18e5
Author: Sam Wheating <[email protected]>
AuthorDate: Wed Jan 31 06:47:35 2024 -0800

    Displaying "actual" try number in TaskInstance view (#34635)
    
    (cherry picked from commit ce6ac4176445efbd6097cdcdb10782752a4f1bf9)
---
 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 b653964580..cbbc2b726c 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -1421,6 +1421,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 4bf06d35c7..5252d20ce3 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -5483,7 +5483,7 @@ class TaskInstanceModelView(AirflowModelView):
         "priority_weight",
         "queue",
         "queued_dttm",
-        "try_number",
+        "prev_attempted_tries",
         "pool",
         "queued_by_job_id",
         "external_executor_id",
@@ -5512,9 +5512,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",

Reply via email to