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

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

commit fb30cbdb941b4cfe11148e7a4de7a825457659fa
Author: Akash Sharma <[email protected]>
AuthorDate: Wed Jul 5 14:00:51 2023 +0530

    Fix try_number shown in the `task?task_id=&dag_id=&execution_date=` (#32361)
    
    * try_number fix
    
    * change test name
    
    (cherry picked from commit a8e4b8aee602e8c672ab879b7392a65b5c2bb34e)
---
 airflow/www/views.py                | 3 ++-
 tests/www/views/test_views_tasks.py | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/airflow/www/views.py b/airflow/www/views.py
index 37b756d332..c29d952583 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -1721,7 +1721,8 @@ class Airflow(AirflowBaseView):
             with warnings.catch_warnings():
                 warnings.simplefilter("ignore", RemovedInAirflow3Warning)
                 all_ti_attrs = (
-                    (name, getattr(ti, name))
+                    # fetching the value of _try_number to be shown under name 
try_number in UI
+                    (name, getattr(ti, "_try_number" if name == "try_number" 
else name))
                     for name in dir(ti)
                     if not name.startswith("_") and name not in 
ti_attrs_to_skip
                 )
diff --git a/tests/www/views/test_views_tasks.py 
b/tests/www/views/test_views_tasks.py
index 8ed25f5614..c63ec5d23e 100644
--- a/tests/www/views/test_views_tasks.py
+++ b/tests/www/views/test_views_tasks.py
@@ -323,6 +323,15 @@ def test_views_get(admin_client, url, contents):
         check_content_in_response(content, resp)
 
 
+def test_rendered_task_view(admin_client):
+    url = 
f"task?task_id=runme_0&dag_id=example_bash_operator&execution_date={DEFAULT_VAL}"
+    resp = admin_client.get(url, follow_redirects=True)
+    resp_html = resp.data.decode("utf-8")
+    assert resp.status_code == 200
+    assert "<td>_try_number</td>" not in resp_html
+    assert "<td>try_number</td>" in resp_html
+
+
 def test_rendered_k8s(admin_client):
     url = 
f"rendered-k8s?task_id=runme_0&dag_id=example_bash_operator&execution_date={DEFAULT_VAL}"
     with unittest.mock.patch.object(settings, "IS_K8S_OR_K8SCELERY_EXECUTOR", 
True):

Reply via email to