Hope I'm in the right place. Is there a way to cre...
# prefect-ui
r
Hope I'm in the right place. Is there a way to create nested/conditional parameters in the UI? For example, given a dict
{country: [cities_in_counry..]}
, I'd like like a UI widget which first lets me select a country, then one/several/all cities belonging to the chosen country.
c
Currently there isn’t a way to have the input of one parameter be conditional based on another parameter.
r
I see, thanks for the reply. What about a simple filtering of list elements when the user starts typing?
c
You can get a dropdown by using an enum like this
Copy code
from prefect import flow
from enum import Enum

class Bar(str, Enum):
    gratis = 'gratis'
    talement = 'talement'
    cro = 'cro'
    ectorm = 'ectorm'
    torphq = 'torphq'
    organt = 'organt'
    huk = 'huk'

@flow
def foo(bar: Bar = Bar.gratis):
    pass

if __name__ == "__main__":
    foo.serve(
        name="foo",
    )
Not a searchable/filterable list currently but that's on our roadmap for parameter improvements
r
That leads to my next question actually 🙂. We're already using generated enums, which means we must redeploy when new entities are added or removed, to make sure they're (not) in the enum/list of options. Is there a way to make Prefect compute the list of options by calling a Python method when the user creates a new flow run through the UI? The obvious solution here seemed to be to pass the method without calling it, but that doesn't work at the moment. I guess the schema currently is just a YAML/JSON file?
Also, is there an issue I can follow to keep track of progress on the searchable/filterable list-issue?
c
I don’t believe there is any way to have a dynamic list like that. The deployment parameters form is generated based on a json schema that is created from the pydantic type of the flow parameters. We did merge a PR yesterday that will convert all the plain select inputs into ones with searchable options. Let me get that released today so we can at least solve that part.
r
I suspected as much. Thanks for the help!
👍 1