https://prefect.io logo
#prefect-community
Title
# prefect-community
p

Paco Ibañez

05/12/2022, 8:54 PM
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

Zanie

05/12/2022, 8:58 PM
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

Paco Ibañez

05/12/2022, 9:04 PM
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

Zanie

05/12/2022, 9:08 PM
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

Paco Ibañez

05/12/2022, 9:09 PM
nice! thank you so much!
I am already using the client so I will give this approach a try
z

Zanie

05/12/2022, 9:15 PM
👍 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

Paco Ibañez

05/12/2022, 9:20 PM
👍
4 Views