https://prefect.io logo
Title
m

Mansour Zayer

03/16/2023, 7:03 PM
Hello. I see that calling a flow inside another flow (calling a subflow) doesn't allow task methods (such as submit or map). I need to submit runs of a subflow mapped over a list of input. Is there a straightforward way to do this? I saw the docs mentioning AnyIO task groups and asyncio.gather, but it seemed a bit too complicated.
n

Nate

03/17/2023, 12:16 AM
Hi @Mansour Zayer - do you want these subflows to run on the same infrastructure as the parent flow that's calling them?
m

Mansour Zayer

03/17/2023, 1:37 PM
I'm open to both options (subflow runs on their own pods, or on the same pod as the parent flow).
n

Nate

03/17/2023, 1:58 PM
gotcha - here's a fully async example of running subflows on their own infra (if desired) via
run_deployment
we're working on improvements to async subflows (when just calling them like python functions or using submit/map), but right now the simplest way is to do something like
subflow_results = [subflow(i) for i in some_list_of_inputs]
which will not be async
🙌 1