Repository navigation
Document config-backed enum Dag Params - #71180
Conversation
cbebad7 to
fc31540
Compare
bbovenzi
left a comment
There was a problem hiding this comment.
I'm wary of adding a new x-airflow-ui option to declaring params. First the name isn't great. Second, we should define how we plan to expand this in the future.
Second, I am not sure if this closes the old issue because the person asked for a selector or a radio over plain text. I don't think it matters as much which of the two exist.
Third, the radio has no option to unselect when it is an optional param.
cfb5629 to
fc31540
Compare
|
Good afternoon. To clarify the current state of this PR: The trigger form already renders enum values as choices via the existing dropdown support, and this PR experiments with rendering the same enum values as radio buttons via I also agree that the selector vs radio part is secondary. The main missing design question is how Airflow should expose UI presentation preferences for Params in a way that can be extended later. The current Given that, I think there are two possible directions:
I’m happy to take either direction. If maintainers think this PR should define the broader UI extension shape, I can work on that here; otherwise I can reduce this PR to the existing enum dropdown/docs pattern. |
|
Let's go with option 1. I think smaller PRs are always a better start and that gets to the core use-case. |
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.
fc31540 to
2addb56
Compare
|
+1, thank you @fat-catTW! |
* 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 <brent.bovenzi@gmail.com>

Why
Dag authors sometimes need the choices for an enum Param to come from deployment-local
configuration rather than being hard-coded in the Dag file. Airflow already supports this —
the trigger form reads the serialized Param schema, so any list computed while the Dag is
parsed shows up as a dropdown — but nothing in the docs or the examples shows the pattern,
so it isn't obvious that it works.
What
Documents and demonstrates building an enum Param's choices from an external config file:
params.rstnotes that choices can be read from a config file at parse time, and that thetrigger form uses the serialized Params rather than calling any dynamic choice provider
when the form opens.
example_params_ui_tutorial.pygains ascript_interfaceParam whose choices come from acolocated INI file, filtered to the sections with
TYPE = Script.example_params_ui_interfaces.iniis the accompanying config file.No behavior change: enum Params still render as dropdowns, and no new schema fields or UI
code are added.
Scope
An earlier revision of this PR proposed an
x-airflow-ui.widget = "radio"schema hint soenum Params could render as radio buttons. That was dropped after review — the naming and
the expansion story for
x-airflow-uineed to be settled first, and a radio has no way toclear the selection for an optional Param. The dropdown already covers the "selector instead
of free text" ask in #56632, so this PR keeps to the documentation half.
related: #56632
Screenshot
Trigger Dag form showing the
Script interfaceParam rendering as a dropdown with thechoices read from the INI file (
Interface A,Interface C—InterfaceBis filtered outbecause its
TYPEis notScript):Was generative AI tooling used to co-author this PR?
Generated-by: [Codex] following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.