<@ULVA73B9P> Hi Marvin. I want a replacement in th...
# ask-marvin
s
@Marvin Hi Marvin. I want a replacement in the Prefect for this ability in the Airlfow
schedule='@continuous'
m
thought for 132.8 seconds
Short answer: there’s no direct
@continuous
in Prefect, but you can get the same behavior easily. Two good patterns: 1) Automations (recommended, no code) - Create an Automation that triggers “Run deployment” when a flow run for your deployment enters the Completed state. - Result: as soon as a run finishes, the next one is queued immediately. - To avoid overlap, ensure only one run can execute at a time (use a concurrency limit of 1 for this deployment/tag). - Docs: Prefect 3 docs and a good overview: Automations and observability UI steps (brief): - UI > Automations > New - Trigger: Flow run state entered = Completed, filtered to your deployment - Action: Run deployment = the same deployment - Optional: also trigger on Failed if you want it truly relentless 2) Self-chaining flow (one-liner at the end) - Have your flow trigger the next run of its deployment as it finishes. Example:
Copy code
from prefect import flow
from prefect.deployments import run_deployment

@flow
def my_flow():
    # … do work …
    # immediately queue the next run of this same deployment
    run_deployment(name="my-flow/my-deployment")
- Add a guard (param/flag) if you want a way to stop the chain. - Same note on avoiding overlap: use a concurrency limit of 1. Less ideal fallback: a tiny interval schedule plus a concurrency limit of 1. Works, but it’s time-based and can leave gaps or queue bursts. Quick clarifiers so I don’t cheerfully spin your cluster forever: - Should it trigger again on failures too, or only on success? - Do you want strictly one-at-a-time, or can multiple runs overlap?
s
@Marvin Yeah do strictly one-at-a-time
m
thought for 34.1 seconds
Perfect. For strictly one-at-a-time, use either of these—both enforce back-to-back, no overlap: Option A: Automation + deployment concurrency (no code) - Create a deployment with no schedule. - Set its concurrency limit to 1 (deployment-level). - Create an Automation: - Trigger: Flow run state entered = Completed, filter to this deployment - Action: Run deployment (the same one) - Result: As soon as a run completes, the next is queued; overlap is impossible because concurrency=1. Option B: Self-chaining + deployment concurrency (tiny code) - Keep the deployment unscheduled and set concurrency_limit=1. - Trigger the next run from inside your flow:
Copy code
from prefect import flow
from prefect.deployments import run_deployment

@flow
def my_flow():
    # ...do work...
    run_deployment(name="my-flow/my-deployment")  # queues next run immediately
Notes: - Concurrency limit of 1 on the deployment is what guarantees “strictly one-at-a-time,” even if something else tries to trigger runs. - If you want it to continue only on success, set the Automation trigger to Completed only. If you want it truly relentless, you can also trigger on Failed. - To stop the loop, disable the Automation (Option A) or remove/comment the
run_deployment
call (Option B). References you can skim while your coffee cools: - Docs home: Prefect 3 docs - Overview of Automations: Automations and observability Want me to paste the exact UI clicks to set the deployment concurrency limit and Automation?