Is there a good example of nesting flows? Example:...
# ask-community
r
Is there a good example of nesting flows? Example: I want to build a flow that I can call individually, but I also want to map over that flow.
j
Hey Ryan, we generally don’t promote nested flows as a first class operation (prefer to use something like a factory function to generate all the tasks you need and add them to the parent flow) and consequently we don’t directly support this, for example, in Prefect Cloud, However, within Prefect Core, there’s no reason you couldn’t create a task that does nothing but create and execute another Flow. You could map over that task, generating flows all you want 🙂 . This is a strength of Prefect (it’ll do what you ask!) but I’d caution that it mixes abstractions and if there’s a way to use a single flow you’ll probably have an easier time.
r
Hi @Jeremiah!
That makes sense Let me think on that and see what I can come up with Thanks for the explanation!
j
Anytime!
j
Are there examples of doing what @Jeremiah suggested with factory functions?
a
I'll be curious to see it also 🙂