Aaron
07/07/2025, 10:52 AMMarvin
07/07/2025, 10:52 AMMarvin
07/07/2025, 10:53 AMDeployment.build_from_flow()
syntax from Prefect 2.x. Let me show you how to create multiple schedules in Prefect 3.x, which is much more straightforward:
python
from prefect import flow
from prefect.schedules import CronSchedule
@flow
def your_flow():
# your flow code here
pass
if __name__ == "__main__":
flow.deploy(
name="TEST",
work_queue_name="default",
schedules=[
CronSchedule(cron="0 1 * * *"), # runs at 1 AM daily
CronSchedule(cron="0 13 * * *") # runs at 1 PM daily
]
)
Key points:
1. In Prefect 3.x, we use flow.deploy()
instead of Deployment.build_from_flow()
2. Multiple schedules are specified using a list in the schedules
parameter
3. Each schedule can be a different CronSchedule with its own cron expression
You can also modify schedules for an existing deployment through the Prefect UI or using the REST API.
For more details on scheduling options and syntax, you can refer to the Prefect documentation on creating schedules.Aaron
07/07/2025, 10:54 AMMarvin
07/07/2025, 10:54 AMMarvin
07/07/2025, 10:55 AMpython
from prefect.deployments import Deployment
from prefect.orion.schemas.schedules import CronSchedule
from test import flow
deployment = Deployment.build_from_flow(
name="TEST",
flow=flow,
work_queue_name="default",
path='test/',
schedules=[
CronSchedule(cron="0 1 * * *"), # runs at 1 AM daily
CronSchedule(cron="0 13 * * *") # runs at 1 PM daily
]
)
deployment.apply()
Key points:
1. Use the schedules
parameter (plural) instead of schedule
(singular)
2. Provide a list of CronSchedule
objects
3. Each schedule can have its own cron expression
This will create a deployment that runs according to both schedules. You can add as many schedules as you need by adding more CronSchedule
objects to the list.
You can also manage schedules through the Prefect UI after the deployment is created, where you can add, remove, or modify schedules as needed.
For more information about scheduling in Prefect 2.x, you can refer to the Prefect 2.x documentation on schedules.