This is an automated email from the ASF dual-hosted git repository. jedcunningham pushed a commit to branch v2-9-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit df9db0cb15e2acfe768218f5401550c17b302cde Author: Carlos Sánchez Páez <carlos.sanc...@feverup.com> AuthorDate: Thu Apr 25 17:17:47 2024 +0200 Add Grid button to Task Instance view (#39223) (cherry picked from commit 8c556dab0db01324f40685f879b3410a488c834b) --- airflow/www/templates/airflow/task_instance.html | 3 +++ airflow/www/views.py | 6 ++++++ tests/www/views/test_views_tasks.py | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/airflow/www/templates/airflow/task_instance.html b/airflow/www/templates/airflow/task_instance.html index f7faff3a53..9c5953ae28 100644 --- a/airflow/www/templates/airflow/task_instance.html +++ b/airflow/www/templates/airflow/task_instance.html @@ -39,6 +39,9 @@ {{ url_for(endpoint, dag_id=dag.dag_id, task_id=task_id, execution_date=execution_date) }} {%- endif -%} {% endmacro -%} + <li><a href="{{ url_for('Airflow.grid', dag_id=dag.dag_id, dag_run_id=dag_run_id ,task_id=task_id, map_index=map_index) }}"> + <span class="material-icons" aria-hidden="true">grid_on</span> + Grid</a></li> <li><a href="{{ ti_url('Airflow.task') }}"> <span class="material-icons" aria-hidden="true">details</span> Task Instance Details</a></li> diff --git a/airflow/www/views.py b/airflow/www/views.py index 5bdebe5d91..b82f844f71 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -1393,6 +1393,7 @@ class Airflow(AirflowBaseView): show_trigger_form_if_no_params=conf.getboolean( "webserver", "show_trigger_form_if_no_params" ), + dag_run_id=dag_run.run_id if dag_run else "", html_dict=html_dict, dag=dag, task_id=task_id, @@ -1458,6 +1459,7 @@ class Airflow(AirflowBaseView): "airflow/ti_code.html", show_trigger_form_if_no_params=conf.getboolean("webserver", "show_trigger_form_if_no_params"), html_dict=html_dict, + dag_run_id=dag_run.run_id if dag_run else "", dag=dag, task_id=task_id, task_display_name=task.task_display_name, @@ -1522,6 +1524,7 @@ class Airflow(AirflowBaseView): return self.render_template( "airflow/ti_code.html", show_trigger_form_if_no_params=conf.getboolean("webserver", "show_trigger_form_if_no_params"), + dag_run_id=dag_run.run_id if dag_run else "", html_dict={"k8s": content}, dag=dag, task_id=task_id, @@ -1648,6 +1651,7 @@ class Airflow(AirflowBaseView): show_trigger_form_if_no_params=conf.getboolean("webserver", "show_trigger_form_if_no_params"), logs=logs, dag=dag_model, + dag_run_id=ti.run_id if ti else "", title="Log by attempts", dag_id=dag_id, task_id=task_id, @@ -1804,6 +1808,7 @@ class Airflow(AirflowBaseView): show_trigger_form_if_no_params=conf.getboolean("webserver", "show_trigger_form_if_no_params"), task_attrs=task_attrs, ti_attrs=ti_attrs, + dag_run_id=ti.run_id if ti else "", failed_dep_reasons=failed_dep_reasons or no_failed_deps_result, task_id=task_id, execution_date=execution_date, @@ -1856,6 +1861,7 @@ class Airflow(AirflowBaseView): show_trigger_form_if_no_params=conf.getboolean("webserver", "show_trigger_form_if_no_params"), attributes=attributes, task_id=task_id, + dag_run_id=ti.run_id if ti else "", task_display_name=ti.task_display_name, execution_date=execution_date, map_index=map_index, diff --git a/tests/www/views/test_views_tasks.py b/tests/www/views/test_views_tasks.py index 90cc5bbc1c..83f57d0751 100644 --- a/tests/www/views/test_views_tasks.py +++ b/tests/www/views/test_views_tasks.py @@ -159,22 +159,42 @@ def client_ti_without_dag_edit(app): ], id="delete-dag-button-normal", ), + pytest.param( + f"task?task_id=runme_0&dag_id=example_bash_operator&execution_date={DEFAULT_VAL}", + ["Grid"], + id="task-grid-button", + ), pytest.param( f"task?task_id=runme_0&dag_id=example_bash_operator&execution_date={DEFAULT_VAL}", ["Task Instance Details"], id="task", ), + pytest.param( + f"log?task_id=runme_0&dag_id=example_bash_operator&execution_date={DEFAULT_VAL}", + ["Grid"], + id="log-grid-button", + ), pytest.param( f"xcom?task_id=runme_0&dag_id=example_bash_operator&execution_date={DEFAULT_VAL}", ["XCom"], id="xcom", ), + pytest.param( + f"xcom?task_id=runme_0&dag_id=example_bash_operator&execution_date={DEFAULT_VAL}", + ["Grid"], + id="xcom-grid-button", + ), pytest.param("xcom/list", ["List XComs"], id="xcom-list"), pytest.param( f"rendered-templates?task_id=runme_0&dag_id=example_bash_operator&execution_date={DEFAULT_VAL}", ["Rendered Template"], id="rendered-templates", ), + pytest.param( + f"rendered-templates?task_id=runme_0&dag_id=example_bash_operator&execution_date={DEFAULT_VAL}", + ["Grid"], + id="rendered-templates-grid-button", + ), pytest.param( "object/graph_data?dag_id=example_bash_operator", ["runme_1"],