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

bbovenzi 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 50950fa92b7 Document config-backed enum Dag Params (#71180)
50950fa92b7 is described below

commit 50950fa92b791ce25fda7533c2c495d39f016e03
Author: Vincent Hsiao <[email protected]>
AuthorDate: Sat Aug 22 05:01:27 2026 +0800

    Document config-backed enum Dag Params (#71180)
    
    * Document config-backed enum Dag Params
    
    Dag authors can already render fixed scalar Params as dropdowns with JSON 
Schema enums, but the Params documentation did not show how to derive those 
choices from deployment-local configuration. Showing the parse-time pattern 
keeps the trigger form based on serialized Dag Params without introducing a 
dynamic choice provider or new UI schema extension.
    
    * Delete airflow-core/newsfragments/71180.improvement.rst
    
    ---------
    
    Co-authored-by: Brent Bovenzi <[email protected]>
---
 airflow-core/docs/core-concepts/params.rst         |  5 +++++
 .../example_dags/example_params_ui_interfaces.ini  | 25 ++++++++++++++++++++++
 .../example_dags/example_params_ui_tutorial.py     | 24 +++++++++++++++++++++
 3 files changed, 54 insertions(+)

diff --git a/airflow-core/docs/core-concepts/params.rst 
b/airflow-core/docs/core-concepts/params.rst
index 2f70611e88c..94c336918a9 100644
--- a/airflow-core/docs/core-concepts/params.rst
+++ b/airflow-core/docs/core-concepts/params.rst
@@ -253,6 +253,11 @@ The following features are supported in the Trigger UI 
Form:
             * ``format="multiline"``: Generate a multi-line textarea
             * | ``enum=["a", "b", "c"]``: Generates a
               | drop-down select list for scalar values.
+              | If the choices come from an external config file,
+              | read that file while the Dag is parsed and pass the
+              | resulting list to ``enum``; the trigger form reads
+              | the serialized Dag Params and does not call dynamic
+              | choice providers when the form opens.
               | As of JSON validation, a value must be
               | selected or the field must be marked as
               | optional explicit. See also details inside
diff --git 
a/airflow-core/src/airflow/example_dags/example_params_ui_interfaces.ini 
b/airflow-core/src/airflow/example_dags/example_params_ui_interfaces.ini
new file mode 100644
index 00000000000..b24944d4ec6
--- /dev/null
+++ b/airflow-core/src/airflow/example_dags/example_params_ui_interfaces.ini
@@ -0,0 +1,25 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[InterfaceA]
+TYPE = Script
+
+[InterfaceB]
+TYPE = EBICS
+
+[InterfaceC]
+TYPE = Script
diff --git 
a/airflow-core/src/airflow/example_dags/example_params_ui_tutorial.py 
b/airflow-core/src/airflow/example_dags/example_params_ui_tutorial.py
index 279ddf82c71..400a1f76e86 100644
--- a/airflow-core/src/airflow/example_dags/example_params_ui_tutorial.py
+++ b/airflow-core/src/airflow/example_dags/example_params_ui_tutorial.py
@@ -23,12 +23,23 @@ to the DAG and which are used to render a trigger form.
 
 from __future__ import annotations
 
+import configparser
 import datetime
 import json
 from pathlib import Path
 
 from airflow.sdk import DAG, Param, task
 
+
+def _get_script_interfaces_from_config() -> list[str]:
+    config = configparser.ConfigParser()
+    config.read(Path(__file__).with_name("example_params_ui_interfaces.ini"))
+
+    return [section for section in config.sections() if 
config[section].get("TYPE") == "Script"]
+
+
+SCRIPT_INTERFACES = _get_script_interfaces_from_config()
+
 with DAG(
     dag_id=Path(__file__).stem,
     dag_display_name="Params UI tutorial",
@@ -75,6 +86,19 @@ with DAG(
             enum=[f"value {i}" for i in range(16, 64)],
             section="Typed parameters with Param object",
         ),
+        "script_interface": Param(
+            SCRIPT_INTERFACES[0],
+            description="Choices are generated from 
example_params_ui_interfaces.ini at Dag parse time.",
+            schema={
+                "type": "string",
+                "title": "Script interface",
+                "enum": SCRIPT_INTERFACES,
+                "values_display": {
+                    name: name.replace("Interface", "Interface ") for name in 
SCRIPT_INTERFACES
+                },
+                "section": "Typed parameters with Param object",
+            },
+        ),
         # [END section_1]
         # Boolean as proper parameter with description
         "bool": Param(

Reply via email to