Robert Banick
11/12/2024, 3:48 PMNone or False when unused. Boolean parameters are content with their False default but String and Array[str, str] parameters are failing when passed None. See below screenshot.
Passing "" and [] as defaults did not resolve the problem and is anyways problematic for the execution code. Abandoning quick runs is of course not an option. Can someone on Prefect advise how best to resolve this issue?Robert Banick
11/12/2024, 3:49 PMValidate parameters at the bottom?Robert Banick
11/12/2024, 3:49 PMNate
11/12/2024, 3:49 PMRobert Banick
11/12/2024, 3:50 PMdate_range and temporary_storage_bucket parameters are causing the quick run failures
def cpc_flows(
dataset_name: str,
collection: str = "CPC",
temporal_resolution: str = "daily",
date_range: list[str, str] = [],
temporary_storage_bucket: str = "",
):Robert Banick
11/12/2024, 3:51 PMNoneNate
11/12/2024, 3:51 PMdate_range: list[str, str] = [],I would keep this defaulting to None, for this reason, and then something like
if not x:
x = []
inside your flowRobert Banick
11/12/2024, 3:55 PMValidate parameters however. I will just need to switch that off then, there's no way to satisfy it with a None default?Nate
11/12/2024, 3:56 PMthere's no way to satisfy it with aif you havedefault?None
date_range: list[str, str] | None = None
it should do the right thingNate
11/12/2024, 3:56 PMdate_range: list[str, str] = None
is a lie and it confuses the UIRobert Banick
11/12/2024, 3:56 PMRobert Banick
11/12/2024, 3:58 PMNate
11/12/2024, 4:03 PMfrom prefect import flow
@flow
def takes_optional_list(some_list_or_none: list[int] | None = None):
return some_list_or_none
if __name__ == "__main__":
takes_optional_list.serve()Robert Banick
11/12/2024, 4:22 PMserve to deploy our flows, could this have something to do with it? They're deployed with
## imports
source_params = # define source params
deploy_params = # define deploy params
flow.from_source(**source_params).deploy(**deploy_params)Nate
11/12/2024, 4:30 PMRobert Banick
11/12/2024, 4:34 PMTom Jordahl
11/13/2024, 4:19 PMNate
11/13/2024, 4:22 PM@flow
def f(optional_list: list[Any] = None): ...
and will confuse the UI (bc it looks at the result of going signature -> OpenAPI schema) so if None is valid you need a union type like
@flow
def f(optional_list: list[Any] | None = None): ...Tom Jordahl
11/13/2024, 4:23 PMNate
11/13/2024, 4:25 PMTom Jordahl
11/13/2024, 4:26 PMNate
11/13/2024, 4:27 PMTom Jordahl
11/13/2024, 4:33 PM