Skip to content

Commit

Permalink
Fix try_number shown in the task?task_id=&dag_id=&execution_date= (#…
Browse files Browse the repository at this point in the history
…32361)

* try_number fix

* change test name

(cherry picked from commit a8e4b8a)
  • Loading branch information
Adaverse authored and ephraimbuddy committed Jul 6, 2023
1 parent bc7516b commit fb30cbd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
9 changes: 9 additions & 0 deletions tests/www/views/test_views_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit fb30cbd

Please sign in to comment.