<@ULVA73B9P> i have a prefect flow that run every ...
# marvin-in-the-wild
d
@Marvin i have a prefect flow that run every minute to scrap an information only avalable once in a day. i have set up a cron for every minu run. But once my flow is marked as a success i would like the cron to stop for the day whats the best way to do this
m
To achieve a functionality where your flow stops scheduling after a successful run for the remainder of the day, Prefect does not offer an out-of-the-box setting that directly enables a cron schedule to be deactivated after a flow run succeeds. However, you can handle this programmatically within your flow or by utilizing an external control mechanism. Here's a couple of potential approaches: 1. Implement a Manual Check: Within your flow, you can implement a check at the beginning to see if the flow has already successfully run that day. If it has, you can terminate the run early. 2. Use Deployment's Active Flag: You could alter the
active
flag of the deployment through the API or the UI manually or programmatically to disable and enable the schedule. This can be automated by a separate process that monitors flow runs and toggles the
active
state of the deployment after a successful run. 3. Custom Scheduler Logic: Create a custom script that interacts with the Prefect API to schedule flow runs dynamically, rather than relying on a cron schedule. This script could schedule the next flow run for the following day after a successful run. The important links here are Schedules in Prefect which could help understand how schedules can be activated or deactivated and Using the Prefect Client, which shows how to programmatically interact with flow runs. For a more detailed solution tailored to Prefect 2.x, we might dive into the documentation further or examine recent user strategies on GitHub issues. Would you like me to look for specific examples or commands that may assist in solving this?