Chu
08/02/2022, 2:30 PMTypeError: `fn` must be callable
I’m calling a task inside a With Flow statement, and the Task should return me a list of stringsNate
08/02/2022, 2:41 PMprefect version ?
I suspect you're writing prefect 1.0 code using prefect>=2.0Chu
08/02/2022, 2:45 PMChu
08/02/2022, 2:46 PMNate
08/02/2022, 2:46 PMChu
08/02/2022, 2:48 PMparams = Parameter("ids", default=['a','b','c'])
like to deserialize params to [‘a’,‘b’,‘c’]Nate
08/02/2022, 2:55 PMParameter object is a special type of task, so within the with Flow(...) as flow: block (called the flow context) the return of your task will be of type prefect.tasks.core.function.FunctionTask and you cannot [sic] access the true value (a list in your case) in the flow context
however, when you pass this Parameter to a downstream task, you can treat it as a list like you'd expect, for example you could have
@task(log_stdout=True)
def my_downstream_task(my_params: List[str]):
print(type(my_params))
print(my_params)
# do other things with your params
with Flow('my flow') as flow:
params = Parameter("ids", default=['a','b','c'])
my_task_result = my_downstream_task(params)
if __name__ == "__main__":
flow.run()Chu
08/02/2022, 2:55 PMparams.defaultChu
08/02/2022, 2:56 PMNate
08/02/2022, 2:58 PMChu
08/02/2022, 3:06 PMChu
08/02/2022, 3:12 PMNate
08/02/2022, 3:16 PMChu
08/02/2022, 3:18 PM