Hey community! Is there a way to run a flow inside...
# ask-community
a
Hey community! Is there a way to run a flow inside a different flow? I mean suppose I have an existing flow and want to trigger it as part of a different flow, without specifying the flow again. Is there a way to do that? e.g. a Task that wraps an existing flow? Preferably a flow that is registered to the orchestration server?
z
Hi @Avi A! If I'm understanding properly, you want to kick off a new flow run from within a flow. While I wouldn't recommend wrapping an existing flow in a task (things can get wonky that way), you can use your orchestration layer to use the Flow Run Task and kick off a new flow run. https://docs.prefect.io/api/latest/tasks/cloud.html#flowruntask
a
got it, thanks. so I understand this functionality works only with cloud, and not with the core server?
related: can I specify a return value for a flow, the same way we do it for tasks? I looked in the docs and couldn’t find something about it
z
Actually, I think you've spotted a chance for us to improve our documentation! Looks like the docs I linked are pre-server, but I just tested and you can use the
FlowRunTask
with server as well. It's worth noting that you won't want to provide a project name if running this with Prefect Server as your orchestration layer eg
fr_test = FlowRunTask(flow_name="hello-flow")
👏 1
And I'm unsure of return values for flows-- let me poke around and see if I can find an answer for you! Edit: following up, it looks like there's not currently a way to specify a return value for a flow.
a
thanks a lot, I’ll give it a go soon!
z
Sounds good! I'm a fan of this task-- hope you are too. 🙂
a
thanks for following up! actually looking deeper into the doc and the source code it seems that this task only triggers the flow, but doesn’t wait for it
it means that if I put it as part of my second flow it doesn’t really wait for it to finish, and the downstream tasks can’t rely on its artifacts
z
That's correct-- it'll send an API call to your orchestration layer to create a new, scheduled flow run, but will not wait for that flow run.
👍 1