Tanishq Hooda
05/09/2024, 9:58 AMMarvin
05/09/2024, 9:59 AMschedules
parameter in the flow.deploy
function. Let me refine my search and try to get you a more relevant example. Please wait a moment.
I apologize for the inconvenience. It seems that finding a direct code example for using the schedules
parameter in flow.deploy
is more challenging than I expected. However, I found some documentation that might help you:
1. The tutorial on deployments discusses using the to_deployment
method to create deployments. This method exposes the exact same options as flow.serve
, and you can use intervals for scheduling.
@flow
def slow_flow(sleep: int = 60):
"Sleepy flow - sleeps the provided amount of time (in seconds)."
time.sleep(sleep)
@flow
def fast_flow():
"Fastest flow this side of the Mississippi."
return
if __name__ == "__main__":
slow_deploy = slow_flow.to_deployment(name="sleeper", interval=45)
fast_deploy = fast_flow.to_deployment(name="fast")
serve(slow_deploy, fast_deploy)
2. The concepts of schedules in Prefect's documentation, which explains different methods for creating schedules, such as through the Prefect UI, via the cron
, interval
, or rrule
parameters, or by passing schedules
into the Deployment
class or Deployment.build_from_flow
.
Unfortunately, these pieces of documentation do not include explicit Python code examples using the schedules
parameter in flow.deploy
. The deployment process might be slightly different in newer Prefect versions, so I suggest checking out the most recent documentation and experimenting within the Prefect UI for the most up-to-date information on scheduling deployments.