From fb30cbdb941b4cfe11148e7a4de7a825457659fa Mon Sep 17 00:00:00 2001 From: Akash Sharma <35839624+Adaverse@users.noreply.github.com> Date: Wed, 5 Jul 2023 14:00:51 +0530 Subject: [PATCH] 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 37b756d33242f..c29d952583568 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -1721,7 +1721,8 @@ def task(self, session: Session = NEW_SESSION): 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 8ed25f5614113..c63ec5d23e9fa 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 "