👋 hullo folks! have a general question about flows vs. tasks vs. just regular functions in prefect 2.0. are there any high level guidelines on where we may want to use each? i'll try to describe a scenario in the thread
there are a number of scenarios we could structure this where some things are `@flow`s, some things are `@task`s, or there's only one flow at the top and everything else is tasks, or everything is marked as a
@flow
, etc. etc.
Jai P
05/03/2022, 3:15 PM
i guess i'm not looking for the optimal solution for the example above, but more "hey i have a function, when might i want to mark it as a task or a flow, and what are the tradeoffs of doing so"
z
Zanie
05/03/2022, 3:16 PM
A major difference is that flows block execution while tasks are run in the background.
Zanie
05/03/2022, 3:17 PM
If you call a flow, it will not return until its final state is reached. If you call a task, it returns a future immediately and the return value can be retrieved later.
j
Jai P
05/03/2022, 3:20 PM
i can trigger multiple flows in parallel though right? but maybe that adds some clarity about how much you want to deeply nest things as flows
We’re also likely to add an interface for running flows in parallel without using async in the future.
👍 2
🙌 1
j
Jai P
05/03/2022, 7:03 PM
amazing! and again, tasks can't call other tasks right? so if i have a situation where i'd want to, say, programmatically call some set of tasks conditionally, it may be better to have those tasks called via some function rather than a subflow, especially if i don't want the blocking behavior
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.