From 57d407726738c6ad695118603a7f1a6ca69fc41d Mon Sep 17 00:00:00 2001 From: jyotidhiman0610 Date: Tue, 29 Dec 2020 19:52:44 +0530 Subject: [PATCH 1/4] Add DAG Docs to Trigger UI --- airflow/www/templates/airflow/trigger.html | 1 + 1 file changed, 1 insertion(+) diff --git a/airflow/www/templates/airflow/trigger.html b/airflow/www/templates/airflow/trigger.html index 3c4488ba9ed1f..7f25168e73fee 100644 --- a/airflow/www/templates/airflow/trigger.html +++ b/airflow/www/templates/airflow/trigger.html @@ -18,6 +18,7 @@ #} {% extends base_template %} +{% from 'appbuilder/dag_docs.html' import dag_docs %} {% block content %} {{ super() }} From f81fce779c85153c44882c787271f3258822102d Mon Sep 17 00:00:00 2001 From: jyotidhiman0610 Date: Wed, 30 Dec 2020 15:57:07 +0530 Subject: [PATCH 2/4] Add DAG docs to Trigger UI --- airflow/www/templates/airflow/trigger.html | 1 + airflow/www/views.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/airflow/www/templates/airflow/trigger.html b/airflow/www/templates/airflow/trigger.html index 7f25168e73fee..bfc8f0f9038af 100644 --- a/airflow/www/templates/airflow/trigger.html +++ b/airflow/www/templates/airflow/trigger.html @@ -23,6 +23,7 @@ {% block content %} {{ super() }}

Trigger DAG: {{ dag_id }}

+ {{ dag_docs(doc_md) }}
diff --git a/airflow/www/views.py b/airflow/www/views.py index 7aa7dea5e0b51..1a67a95fd8596 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -1414,11 +1414,13 @@ def trigger(self, session=None): else: try: dag = current_app.dag_bag.get_dag(dag_id) + + doc_md = wwwutils.wrapped_markdown(getattr(dag, 'doc_md', None)) 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() From 86d05b7144bf05283ca9e09bf9f3514ec0f0f721 Mon Sep 17 00:00:00 2001 From: jyotidhiman0610 Date: Wed, 6 Jan 2021 11:16:26 +0530 Subject: [PATCH 3/4] Add docs_md param in tests --- tests/www/test_views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/www/test_views.py b/tests/www/test_views.py index 454ba6b137d59..fbe9c15696c94 100644 --- a/tests/www/test_views.py +++ b/tests/www/test_views.py @@ -2783,12 +2783,13 @@ def test_trigger_dag_params_conf(self, request_conf, expected_conf): 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("\"", """) From 652db81b578ee7730865bf854d0398f77874f2ec Mon Sep 17 00:00:00 2001 From: jyotidhiman0610 Date: Wed, 6 Jan 2021 11:27:18 +0530 Subject: [PATCH 4/4] Show DAG docs when conf is available --- airflow/www/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/airflow/www/views.py b/airflow/www/views.py index 1a67a95fd8596..3bfa7c487e7ea 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -1409,13 +1409,14 @@ def trigger(self, session=None): 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) - - doc_md = wwwutils.wrapped_markdown(getattr(dag, 'doc_md', None)) default_conf = json.dumps(dag.params, indent=4) except TypeError: flash("Could not pre-populate conf field due to non-JSON-serializable data-types")