From 79ec7761e4e5c54cb68e57cdcdea28ead91048bc Mon Sep 17 00:00:00 2001 From: Jens Scheffler Date: Sat, 12 Aug 2023 18:48:28 +0200 Subject: [PATCH 1/4] Make skip of trigger form in UI if no params are defined configurable --- airflow/config_templates/config.yml | 9 +++++++++ airflow/www/views.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/airflow/config_templates/config.yml b/airflow/config_templates/config.yml index 238e8a9b01b45..81e8b5cf50c29 100644 --- a/airflow/config_templates/config.yml +++ b/airflow/config_templates/config.yml @@ -1779,6 +1779,15 @@ webserver: type: string example: "sha256" default: "md5" + skip_trigger_form_if_no_params: + description: | + Behavior of the trigger DAG run button for DAGs without params. True to skip and trigger + without displaying a form to add a dag_run.conf, False to always display the form. + The form is displayed always if parameters are defined. + version_added: 2.7.0 + type: boolean + example: ~ + default: "True" email: description: | Configuration email backend and whether to diff --git a/airflow/www/views.py b/airflow/www/views.py index 8bd59ab35c594..51aeb44f836a7 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -2031,6 +2031,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION): form_fields[k]["schema"]["custom_html_form"] ) ui_fields_defined = any("const" not in f["schema"] for f in form_fields.values()) + show_form_if_no_params = not conf.getboolean("webserver", "skip_trigger_form_if_no_params") if not dag_orm: flash(f"Cannot find dag {dag_id}") @@ -2057,7 +2058,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION): 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_form_if_no_params): # Populate conf textarea with conf requests parameter, or dag.params default_conf = "" From 0dd758be77f0a64e162fadede2232e407ae86bef Mon Sep 17 00:00:00 2001 From: Jens Scheffler Date: Sat, 12 Aug 2023 20:15:01 +0200 Subject: [PATCH 2/4] Review feedback, remove negating bool --- airflow/config_templates/config.yml | 8 ++++---- airflow/www/views.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/airflow/config_templates/config.yml b/airflow/config_templates/config.yml index 81e8b5cf50c29..cf1ba9b5608d9 100644 --- a/airflow/config_templates/config.yml +++ b/airflow/config_templates/config.yml @@ -1779,15 +1779,15 @@ webserver: type: string example: "sha256" default: "md5" - skip_trigger_form_if_no_params: + show_trigger_form_if_no_params: description: | - Behavior of the trigger DAG run button for DAGs without params. True to skip and trigger - without displaying a form to add a dag_run.conf, False to always display the form. + 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: "True" + default: "False" email: description: | Configuration email backend and whether to diff --git a/airflow/www/views.py b/airflow/www/views.py index 51aeb44f836a7..19af1c48e2161 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -2031,7 +2031,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION): form_fields[k]["schema"]["custom_html_form"] ) ui_fields_defined = any("const" not in f["schema"] for f in form_fields.values()) - show_form_if_no_params = not conf.getboolean("webserver", "skip_trigger_form_if_no_params") + show_form_if_no_params = conf.getboolean("webserver", "show_trigger_form_if_no_params") if not dag_orm: flash(f"Cannot find dag {dag_id}") From 3e859a1cc165f487357f81518569a4dd1fc847b6 Mon Sep 17 00:00:00 2001 From: Jens Scheffler Date: Sat, 12 Aug 2023 20:22:14 +0200 Subject: [PATCH 3/4] Review feedback, remove negating bool --- airflow/www/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airflow/www/views.py b/airflow/www/views.py index 19af1c48e2161..697b7674dca36 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -2031,7 +2031,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION): form_fields[k]["schema"]["custom_html_form"] ) ui_fields_defined = any("const" not in f["schema"] for f in form_fields.values()) - show_form_if_no_params = conf.getboolean("webserver", "show_trigger_form_if_no_params") + 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}") @@ -2058,7 +2058,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION): if isinstance(run_conf, dict) and any(run_conf) } - if request.method == "GET" and (ui_fields_defined or show_form_if_no_params): + 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 = "" From b9ae0790cfd48846a70b61740962f8603207e2f2 Mon Sep 17 00:00:00 2001 From: Jens Scheffler Date: Sun, 13 Aug 2023 10:52:24 +0200 Subject: [PATCH 4/4] Add newsfragment --- newsfragments/33351.significant.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 newsfragments/33351.significant.rst diff --git a/newsfragments/33351.significant.rst b/newsfragments/33351.significant.rst new file mode 100644 index 0000000000000..d8f91c4c2028f --- /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 `_ +* Enable the new configuration ``show_trigger_form_if_no_params`` to bring back old behaviour