to the task decorator/constructor, or provide a
return-type annotation to your task.` but I can't use
because I don't know the result size and it is not a good fit for Tuple (since it's a list of tuple)
As you said, this is only useful if you know your output length in advance. Check your code whether if you are doing something similar. Otherwise, there is nothing wrong about returning lists. From there, you can either pass the entire list to downstream tasks, or use mapping to iterate over each list element and create a downstream task per element.
n1, n2 = MyTask()
list( ... )
to wrap the metrics and results in the monadic task value.
task(lambda as, xs: set(as).difference(xs), name="intersection")(metrics, results)
is not a prefect task.
is actually a
object that represents a tasks result. If you call a barebones
over a task, python tries to iterate the task object and the error above happens.
function to return
where TRes is the actually non-wrapped function's return type?
annotations does this
is resolved as
task1 + task2
by prefect. But resolving arbitrary func calls like
to a prefect task is not possible at this point
In general, users will not instantiate these tasks by hand; they will automatically be...
would get resolved into a
task definition, in this sense they are implicit. calling pythons default
function cannot be detected by prefect however
I would have gotten the set of things automatically cast?
def handle(xs: Set[Thing]) -> None:
@task def ret1(): return 1 @task def ret2(): return 2 @task def print_content(x): print(x) with Flow("ListTest") as f: print_content([ret1, ret2])
operator created a list of 2 prefect tasks. and prefect, while building the flow, understood that the output of these two tasks should be appended in a list. And inserted a
task to facilitate this.
call however would try to iterate over tasks, because the
function assumes its inputs are iterable. You will simply get the above error, even before building a python list of tasks. Because task objects are not iterable.