Hello! 2.0 question: I am trying to build a flow t...
# prefect-community
p
Hello! 2.0 question: I am trying to build a flow that uses other flows that have already been registered in Prefect. Is there a way to define the new flow referencing the existing flows? All the examples I have seen declare the main flow and subflows at the same time and in the same file. Thanks!
z
We don’t have great support for creating runs within a flow for deployments yet, it’s on the roadmap but there’s not a simple UX yet.
p
Thanks for your response! I can use the client, but I am not sure I understand how to do it. Assuming I have flow1 and flow2 with their respective deployments, how could I create a flow/deployment that runs flow1/deployment_a and flow2/deployment_b?
z
Copy code
from prefect import get_client, task

@task
async def create_flow_run_from_deployment(deployment_id):
    async with get_client() as client:
        await client.create_flow_run_from_deployment(deployment_id)
You could use a task like this in the first flow
Copy code
@flow
def my_orchestrator():
    create_flow_run_from_deployment("sfasf-sfas-ffsfa-sfas")
I’d recommend waiting until we have a first-class experience if this is confusing.
p
nice! thank you so much!
I am already using the client so I will give this approach a try
z
👍 sweet. This will create the run and an agent will have to execute it. It won’t wait for completion. To do that, you’d have to read the flow run on an interval and check the state.
p
👍