James Phoenix

    James Phoenix

    1 year ago
    client.create_flow_run(flow_id="<flow id>")
    emre

    emre

    1 year ago
    not quite, with this you tell the prefect server that an instance of this flow needs to be run somewhere. This could be picked by any prefect agent communicating with your server. You need to run a prefect agent in your flask route. That prefect agent can then pick up flows with
    LocalRun
    run_configs, and run them in the agent process.
    If you are building the flow in the flask route as well, check out
    run_agent
    :https://github.com/PrefectHQ/prefect/blob/8ce99d9752b175eeaf8a0b15ba3d0a80c221b69e/src/prefect/core/flow.py#L1543 This, if I remember correctly, registers the flow with the correct run config, starts an agent locally, and tells server to start a flow run, which only the local agent can pick up.
    If your flow is already registered, try spinning up a
    LocalAgent
    in the flask route yourself:https://github.com/PrefectHQ/prefect/blob/master/src/prefect/agent/local/agent.py Note that you NEED your flow to be configured with
    LocalRun
    if you want the flow to run in the agent process.
    James Phoenix

    James Phoenix

    1 year ago
    Legend, thanks man!