This is an automated email from the ASF dual-hosted git repository.

msumit 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 d7aed84  Add note about params on trigger DAG page (#18166)
d7aed84 is described below

commit d7aed84f64c900d636b29328fd76f91ab34d6ca5
Author: Sumit Maheshwari <msu...@users.noreply.github.com>
AuthorDate: Sun Sep 12 13:34:20 2021 +0530

    Add note about params on trigger DAG page (#18166)
---
 airflow/www/templates/airflow/trigger.html |  7 +++++++
 airflow/www/views.py                       | 23 ++++++++++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/airflow/www/templates/airflow/trigger.html 
b/airflow/www/templates/airflow/trigger.html
index 4ae838f..fb1fd88 100644
--- a/airflow/www/templates/airflow/trigger.html
+++ b/airflow/www/templates/airflow/trigger.html
@@ -47,6 +47,13 @@
     </div>
     <p>
       To access configuration in your DAG use <code>{{ '{{ dag_run.conf }}' 
}}</code>.
+      {% if is_dag_run_conf_overrides_params %}
+        As <code>core.dag_run_conf_overrides_params</code> is set to 
<code>True</code>, so passing any configuration
+        here will override task params which can be accessed via <code>{{ '{{ 
params }}' }}</code>.
+      {% else %}
+        As <code>core.dag_run_conf_overrides_params</code> is set to 
<code>False</code>, so passing any configuration
+        here won't override task params.
+      {% endif %}
     </p>
     <div class="form-group">
       <label class="switch-label">
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 1423568..968770f 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -1625,6 +1625,7 @@ class Airflow(AirflowBaseView):
         unpause = request.values.get('unpause')
         request_conf = request.values.get('conf')
         request_execution_date = request.values.get('execution_date', 
default=timezone.utcnow().isoformat())
+        is_dag_run_conf_overrides_params = conf.getboolean('core', 
'dag_run_conf_overrides_params')
 
         if request.method == 'GET':
             # Populate conf textarea with conf requests parameter, or 
dag.params
@@ -1648,6 +1649,7 @@ class Airflow(AirflowBaseView):
                 conf=default_conf,
                 doc_md=doc_md,
                 form=form,
+                
is_dag_run_conf_overrides_params=is_dag_run_conf_overrides_params,
             )
 
         dag_orm = session.query(models.DagModel).filter(models.DagModel.dag_id 
== dag_id).first()
@@ -1661,7 +1663,12 @@ class Airflow(AirflowBaseView):
             flash("Invalid execution date", "error")
             form = DateTimeForm(data={'execution_date': 
timezone.utcnow().isoformat()})
             return self.render_template(
-                'airflow/trigger.html', dag_id=dag_id, origin=origin, 
conf=request_conf, form=form
+                'airflow/trigger.html',
+                dag_id=dag_id,
+                origin=origin,
+                conf=request_conf,
+                form=form,
+                
is_dag_run_conf_overrides_params=is_dag_run_conf_overrides_params,
             )
 
         dr = DagRun.find(dag_id=dag_id, execution_date=execution_date, 
run_type=DagRunType.MANUAL)
@@ -1677,13 +1684,23 @@ class Airflow(AirflowBaseView):
                     flash("Invalid JSON configuration, must be a dict", 
"error")
                     form = DateTimeForm(data={'execution_date': 
execution_date})
                     return self.render_template(
-                        'airflow/trigger.html', dag_id=dag_id, origin=origin, 
conf=request_conf, form=form
+                        'airflow/trigger.html',
+                        dag_id=dag_id,
+                        origin=origin,
+                        conf=request_conf,
+                        form=form,
+                        
is_dag_run_conf_overrides_params=is_dag_run_conf_overrides_params,
                     )
             except json.decoder.JSONDecodeError:
                 flash("Invalid JSON configuration, not parseable", "error")
                 form = DateTimeForm(data={'execution_date': execution_date})
                 return self.render_template(
-                    'airflow/trigger.html', dag_id=dag_id, origin=origin, 
conf=request_conf, form=form
+                    'airflow/trigger.html',
+                    dag_id=dag_id,
+                    origin=origin,
+                    conf=request_conf,
+                    form=form,
+                    
is_dag_run_conf_overrides_params=is_dag_run_conf_overrides_params,
                 )
 
         dag = current_app.dag_bag.get_dag(dag_id)

Reply via email to