Hi guys, I am wondering something about prefect 3....
# ask-community
j
Hi guys, I am wondering something about prefect 3.0 and I am curious about how community is developing flows right now. As it is said in the official doc "Prefect future objects must be resolved explicitly before returning from a flow". That means that every task must be resolved during the flow execution. In prefect 2.0, all tasks were automatically waited. In fact, the flow returned a list of tasks states. Right now, how are you developing your flows? 1. Do not use
.submit
for the terminal futures? 2. Use
.wait()
for terminal futures, and return a list of tasks states manually? 3. Use the
wait
utilities to resolve terminal futures?
f
I add all my terminal futures to a list and wait for them at the end of my flow. I can't say for sure this is the recommended approach though!
Copy code
for future in futures:
    future.result()
w
I was hoping that Prefect would expose some utility like "wait for all pending futures" that would be neat. In the meanwhile we are explicit returning always the state (regardless if we are using or not) just to ensure the check/ enforced that the flow fails if something went wrong
n
hi @jcozar I don't think there's one right answer, it depends on what you're doing the main changes that occurred (which I talk about

hereā–¾

) is that 1.
.submit
and
.map
are always sync, regardless of the underlying decorated functions 2. we will not proactively go find and wait for futures in cases where you do not • pass the future to another task •
return
it explicitly so if you're passing your futures to another task, or returning your terminal futures from your flow, nothing should change
1. Do not use
.submit
for the terminal futures?
.submit
is a method on a task. so if you call
my_task.submit(...)
the result of that call is a future. if you don't pass that future to another task or
return
it from your flow before you exit the scope of the flow, then python will garbage collect your future (in keeping with
concurrent.futures
behavior)
1. Use
.wait()
for terminal futures, and return a list of tasks states manually?
this is valid if this is what's most convenient for your case, though you don't have to return anything,
.wait()
is an escape hatch to make sure your futures resolve before moving on (even if you don't want to return anything)
1. Use the
wait
utilities to resolve terminal futures?
same as above let me know if that doesn't answer your question
@William Jamir would be happy to see a discussion on what DX you're imagining / what is falling short today!
j
First of all thank you all for your time and answers! I do the same that @William Jamir , just to ensure that I didn't forget to wait some future. However, I understand that the actual behaviour of prefect flows is more transparent, I just need to get used to it šŸ™‚
šŸ‘ 1
n
this section might be useful, as far as making sure you capture and represent failures
j
Thank you @Nate!