You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2023/08/13 12:57:15 UTC

[airflow] branch main updated: Make skip of trigger form in UI if no params are defined configurable (#33351)

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

ephraimanierobi 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 c0362923fd Make skip of trigger form in UI if no params are defined configurable (#33351)
c0362923fd is described below

commit c0362923fd8250328eab6e60f0cf7e855bfd352e
Author: Jens Scheffler <95...@users.noreply.github.com>
AuthorDate: Sun Aug 13 14:57:07 2023 +0200

    Make skip of trigger form in UI if no params are defined configurable (#33351)
    
    * Make skip of trigger form in UI if no params are defined configurable
    
    * Review feedback, remove negating bool
    
    * Review feedback, remove negating bool
    
    * Add newsfragment
---
 airflow/config_templates/config.yml | 9 +++++++++
 airflow/www/views.py                | 3 ++-
 newsfragments/33351.significant.rst | 6 ++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/airflow/config_templates/config.yml b/airflow/config_templates/config.yml
index 238e8a9b01..cf1ba9b560 100644
--- a/airflow/config_templates/config.yml
+++ b/airflow/config_templates/config.yml
@@ -1779,6 +1779,15 @@ webserver:
       type: string
       example: "sha256"
       default: "md5"
+    show_trigger_form_if_no_params:
+      description: |
+        Behavior of the trigger DAG run button for DAGs without params. False to skip and trigger
+        without displaying a form to add a dag_run.conf, True to always display the form.
+        The form is displayed always if parameters are defined.
+      version_added: 2.7.0
+      type: boolean
+      example: ~
+      default: "False"
 email:
   description: |
     Configuration email backend and whether to
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 8bd59ab35c..697b7674dc 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -2031,6 +2031,7 @@ class Airflow(AirflowBaseView):
                     form_fields[k]["schema"]["custom_html_form"]
                 )
         ui_fields_defined = any("const" not in f["schema"] for f in form_fields.values())
+        show_trigger_form_if_no_params = conf.getboolean("webserver", "show_trigger_form_if_no_params")
 
         if not dag_orm:
             flash(f"Cannot find dag {dag_id}")
@@ -2057,7 +2058,7 @@ class Airflow(AirflowBaseView):
             if isinstance(run_conf, dict) and any(run_conf)
         }
 
-        if request.method == "GET" and ui_fields_defined:
+        if request.method == "GET" and (ui_fields_defined or show_trigger_form_if_no_params):
             # Populate conf textarea with conf requests parameter, or dag.params
             default_conf = ""
 
diff --git a/newsfragments/33351.significant.rst b/newsfragments/33351.significant.rst
new file mode 100644
index 0000000000..d8f91c4c20
--- /dev/null
+++ b/newsfragments/33351.significant.rst
@@ -0,0 +1,6 @@
+The trigger UI form is skipped in web UI with 2.7.0 if no parameters are defined in a DAG.
+
+If you are using ``dag_run.conf`` dictionary and web UI JSON entry to run your DAG you should either:
+
+* `Add params to your DAG <https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/params.html#use-params-to-provide-a-trigger-ui-form>`_
+* Enable the new configuration ``show_trigger_form_if_no_params`` to bring back old behaviour