You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2021/01/07 02:33:34 UTC
[airflow] branch master updated: Add DAG Description Doc to Trigger
UI Page (#13365)
This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new 0e510b2 Add DAG Description Doc to Trigger UI Page (#13365)
0e510b2 is described below
commit 0e510b2f2bb03ed9344df664b123920e70382fd1
Author: Jyoti Dhiman <36...@users.noreply.github.com>
AuthorDate: Thu Jan 7 08:03:23 2021 +0530
Add DAG Description Doc to Trigger UI Page (#13365)
closes #12550
---
airflow/www/templates/airflow/trigger.html | 2 ++
airflow/www/views.py | 7 +++++--
tests/www/test_views.py | 3 ++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/airflow/www/templates/airflow/trigger.html b/airflow/www/templates/airflow/trigger.html
index 3c4488b..bfc8f0f 100644
--- a/airflow/www/templates/airflow/trigger.html
+++ b/airflow/www/templates/airflow/trigger.html
@@ -18,10 +18,12 @@
#}
{% extends base_template %}
+{% from 'appbuilder/dag_docs.html' import dag_docs %}
{% block content %}
{{ super() }}
<h2>Trigger DAG: {{ dag_id }}</h2>
+ {{ dag_docs(doc_md) }}
<form method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<input type="hidden" name="dag_id" value="{{ dag_id }}">
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 7aa7dea..3bfa7c4 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -1409,16 +1409,19 @@ class Airflow(AirflowBaseView): # noqa: D101 pylint: disable=too-many-public-m
if request.method == 'GET':
# Populate conf textarea with conf requests parameter, or dag.params
default_conf = ''
+
+ dag = current_app.dag_bag.get_dag(dag_id)
+ doc_md = wwwutils.wrapped_markdown(getattr(dag, 'doc_md', None))
+
if request_conf:
default_conf = request_conf
else:
try:
- dag = current_app.dag_bag.get_dag(dag_id)
default_conf = json.dumps(dag.params, indent=4)
except TypeError:
flash("Could not pre-populate conf field due to non-JSON-serializable data-types")
return self.render_template(
- 'airflow/trigger.html', dag_id=dag_id, origin=origin, conf=default_conf
+ 'airflow/trigger.html', dag_id=dag_id, origin=origin, conf=default_conf, doc_md=doc_md
)
dag_orm = session.query(models.DagModel).filter(models.DagModel.dag_id == dag_id).first()
diff --git a/tests/www/test_views.py b/tests/www/test_views.py
index 454ba6b..fbe9c15 100644
--- a/tests/www/test_views.py
+++ b/tests/www/test_views.py
@@ -2783,12 +2783,13 @@ class TestTriggerDag(TestBase):
2. Conf is passed as a URL parameter -> passed conf json is in textarea
"""
test_dag_id = "example_bash_operator"
+ doc_md = "Example Bash Operator"
if not request_conf:
resp = self.client.get(f'trigger?dag_id={test_dag_id}')
else:
test_request_conf = json.dumps(request_conf, indent=4)
- resp = self.client.get(f'trigger?dag_id={test_dag_id}&conf={test_request_conf}')
+ resp = self.client.get(f'trigger?dag_id={test_dag_id}&conf={test_request_conf}&doc_md={doc_md}')
expected_dag_conf = json.dumps(expected_conf, indent=4).replace("\"", """)