Paco Ibañez

    Paco Ibañez

    4 months ago
    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!
    Michael Adkins

    Michael Adkins

    4 months ago
    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.
    Paco Ibañez

    Paco Ibañez

    4 months ago
    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?
    Michael Adkins

    Michael Adkins

    4 months ago
    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
    @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.
    Paco Ibañez

    Paco Ibañez

    4 months ago
    nice! thank you so much!
    I am already using the client so I will give this approach a try
    Michael Adkins

    Michael Adkins

    4 months ago
    👍 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.
    Paco Ibañez

    Paco Ibañez

    4 months ago
    👍