<@ULVA73B9P> I have multiple flows that I want to ...
# ask-marvin
j
@Marvin I have multiple flows that I want to have under a single deployment. I want them to run as separately as possible, such that if one fails it does not cascade, how can I accomplish this?
m
thought for 97.5 seconds
In Prefect 3.x, a deployment maps to a single flow. So if you have multiple flows and you want them to run independently, the right approach is: create multiple deployments, one per flow, and optionally group them in the same project /
prefect.yaml
/ serve process. If you want failure isolation, do not call one flow directly from another unless you want parent/child behavior. Recommended patterns 1. Best for independence: separate deployments for each flow -
flow_a
-> deployment A -
flow_b
-> deployment B -
flow_c
-> deployment C These can live in the same repo and same
prefect.yaml
, but they are still separate deployments. 2. If one should trigger another without cascading failure: - trigger another deployment - not a direct flow-to-flow call 3. Avoid this if you want isolation:
Copy code
`
   @flow
   def parent():
       flow_a()
       flow_b()
   `
If
flow_a()
fails, that failure is part of the parent run and can affect the whole orchestration. What to do instead Option A: Multiple deployments in one
prefect.yaml
Copy code
yaml
deployments:
  - name: flow-a
    entrypoint: flows.py:flow_a

  - name: flow-b
    entrypoint: flows.py:flow_b

  - name: flow-c
    entrypoint: flows.py:flow_c
Then deploy them with:
Copy code
bash
prefect deploy
I verified the CLI exists: - Deployments docs Option B: Serve multiple deployments together
Copy code
`
from prefect import flow, serve

@flow
def flow_a():
    print("A")

@flow
def flow_b():
    print("B")

@flow
def flow_c():
    print("C")

if __name__ == "__main__":
    serve(
        flow_a.to_deployment(name="flow-a"),
        flow_b.to_deployment(name="flow-b"),
        flow_c.to_deployment(name="flow-c"),
    )
`
This groups them operationally, but each is still its own deployment/run. Option C: Trigger deployments instead of calling flows directly If you need one workflow to kick off others but keep failures isolated, use deployment-triggering patterns rather than direct subflows. Conceptually: - orchestrator starts deployment A - orchestrator starts deployment B - each flow run succeeds/fails independently Rule of thumb - Need true isolation? Separate deployments. - Need shared orchestration state? Subflows/direct flow calls. - Need “grouped but independent”? Multiple deployments in one project. If you'd like, I can show you the exact Prefect 3 pattern for either: 1. multiple deployments from one file, or 2. an orchestrator flow that launches other deployments independently.
j
No. I want all the flows under a single deployment. Since we can track if a flow is what fails, not a deployment