You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/08/19 16:03:46 UTC
[airflow] branch main updated: Stop adding values to rendered templates UI when there is no dagrun (#33516)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new d9814eb3a2 Stop adding values to rendered templates UI when there is no dagrun (#33516)
d9814eb3a2 is described below
commit d9814eb3a2fc1dbbb885a0a2c1b7a23ce1cfa148
Author: Hussein Awala <hu...@awala.fr>
AuthorDate: Sat Aug 19 18:03:39 2023 +0200
Stop adding values to rendered templates UI when there is no dagrun (#33516)
---
airflow/www/views.py | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/airflow/www/views.py b/airflow/www/views.py
index a38752beb1..2be20fcb2a 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -1445,6 +1445,8 @@ class Airflow(AirflowBaseView):
dag_run = dag.get_dagrun(execution_date=dttm, session=session)
raw_task = dag.get_task(task_id).prepare_for_execution()
+ no_dagrun = False
+
title = "Rendered Template"
html_dict = {}
@@ -1457,6 +1459,7 @@ class Airflow(AirflowBaseView):
# database) for presentation only.
ti = TaskInstance(raw_task, map_index=map_index)
ti.dag_run = DagRun(dag_id=dag_id, execution_date=dttm)
+ no_dagrun = True
else:
ti = dag_run.get_task_instance(task_id=task_id, map_index=map_index, session=session)
if ti:
@@ -1502,28 +1505,33 @@ class Airflow(AirflowBaseView):
content = getattr(task, template_field)
renderer = task.template_fields_renderers.get(template_field, template_field)
if renderer in renderers:
- html_dict[template_field] = renderers[renderer](content)
+ html_dict[template_field] = renderers[renderer](content) if not no_dagrun else ""
else:
- html_dict[template_field] = Markup("<pre><code>{}</pre></code>").format(pformat(content))
+ html_dict[template_field] = Markup("<pre><code>{}</pre></code>").format(
+ pformat(content) if not no_dagrun else ""
+ )
if isinstance(content, dict):
if template_field == "op_kwargs":
for key, value in content.items():
renderer = task.template_fields_renderers.get(key, key)
if renderer in renderers:
- html_dict[".".join([template_field, key])] = renderers[renderer](value)
+ html_dict[".".join([template_field, key])] = (
+ renderers[renderer](value) if not no_dagrun else ""
+ )
else:
html_dict[".".join([template_field, key])] = Markup(
"<pre><code>{}</pre></code>"
- ).format(pformat(value))
+ ).format(pformat(value) if not no_dagrun else "")
else:
for dict_keys in get_key_paths(content):
template_path = ".".join((template_field, dict_keys))
renderer = task.template_fields_renderers.get(template_path, template_path)
if renderer in renderers:
content_value = get_value_from_path(dict_keys, content)
- html_dict[template_path] = renderers[renderer](content_value)
-
+ html_dict[template_path] = (
+ renderers[renderer](content_value) if not no_dagrun else ""
+ )
return self.render_template(
"airflow/ti_code.html",
show_trigger_form_if_no_params=conf.getboolean("webserver", "show_trigger_form_if_no_params"),