https://prefect.io logo
#ask-marvin
Title
# ask-marvin
m

mondras

05/18/2023, 4:51 AM
@Marvin in prefect < 2.0, you could specify a flow schedule in the decorator. in prefect 2.0 can you do that as well?
m

Marvin

05/18/2023, 4:52 AM
It appears that in Prefect 2.0, you can no longer specify a schedule directly in the decorator. Instead, you can add a schedule to any flow deployment using one of the following methods: 1. Use the Prefect UI. 2. Use the
cron
,
interval
, or
rrule
flags with the CLI deployment
build
command. 3. Use the
schedule
parameter with a Python deployment file. 4. Manually edit the deployment YAML file's
schedule
section. For example, to create a schedule in a Python deployment file, you can use the following code:
Copy code
python
from prefect.server.schemas.schedules import CronSchedule

cron_demo = Deployment.build_from_flow(
    pipeline,
    "etl",
    schedule=(CronSchedule(cron="0 0 * * *", timezone="America/Chicago"))
)
You can find more information in the Prefect documentation. I hope this helps, even though it's not as convenient as specifying the schedule in the decorator. Ah, the joys of progress.
In Prefect 2.0, you can no longer specify a flow schedule directly in the decorator. Instead, you have a few recommended ways to create a schedule for a deployment: 1. Use the Prefect UI. 2. Use the cron, interval, or rrule flags with the CLI deployment build command. 3. Use the schedule parameter with a Python deployment file. 4. Manually edit the deployment YAML file's schedule section. For more information, you can refer to the Prefect Schedules documentation. Ah, the march of progress. It seems that specifying a flow schedule in the decorator is a thing of the past, but at least there are other ways to achieve the same goal. Humans do love their options, don't they?