prefect
prefect copied to clipboard
UI interprets parameters of type list as strings
Opened from the Prefect Public Slack Community
felix.sonntag: Hey, I was wondering on how to deal/set more complex parameter structures in Prefect Orion. E.g. when I have lists ore nested models, I can’t set them on the UI at all.
felix.sonntag: Building this via prefect deployment build ./param_example.py:example_flow -n example_flow -o example_flow-deployment.yaml
And then applying via:
prefect deployment apply 'example_flow-deployment.yaml'
felix.sonntag: It seems for lists the UI is buggy, it looks like it’s supposed to be able to select lists, but in the end it only takes a string value
anna: great example to reproduce and I was indeed able to reproduce -- thanks for raising that and I'll open an issue
<@ULVA73B9P> open "UI interprets parameters of type list as strings"
Original thread can be found here.
When a deployment is created without default parameters and the user wants to set parameters from the UI, it doesn't work for parameters of the type list.
from typing import List, Dict
from prefect import flow
from pydantic import BaseModel
class NestedParams(BaseModel):
int_param: int
list_param: List[int]
class ExampleParams(BaseModel):
nested: NestedParams = NestedParams(int_param=5, list_param=[1, 2, 3])
list_param: List[float] = [0.1, 0.2]
dict_param: Dict[str, NestedParams] = {
"1": NestedParams(int_param=1, list_param=[2, 3]),
"2": NestedParams(int_param=2, list_param=[3, 3]),
}
@flow
def parametrized(params: ExampleParams):
print("Hello!")
print(params.nested.list_param)
return params.nested.int_param
if __name__ == "__main__":
parametrized(
dict(
nested=dict(int_param=5, list_param=[1, 2, 3]),
list_param=[1, 2, 3],
dict_param={
"1": dict(int_param=5, list_param=[1, 2, 3]),
"2": dict(int_param=5, list_param=[1, 2, 3]),
},
)
)
Flow fails with:
This will either be address as part of https://github.com/PrefectHQ/orion-design/issues/476 which is actively being worked on or it will be address as a follow up to that issue.
Is there any publicly viewable area with the design that's going on and what changes are coming down the pike? This issue is of interest to me, and if there are major changes in this area coming i'm quite interested to learn more.
Hi @Tostino - the changes are a unification of how we handle Python/type related inputs in the ui. Currently the way they're handled in blocks and parameters is slightly different.
almost - those lists defined in dictionaries work, but normal lists are still interpreted as dropdowns