Cannot create Deployment using build_from_flow after update to prefect

I’ve been using this structure until yesterday to create deployments:

deployment = Deployment.build_from_flow(
    flow=workflows,
    name=DEPLOYMENT,
    skip_upload=True,
    schedule = CronSchedule(cron="0 */4 * * *", timezone="Europe/Copenhagen")
    )

if __name__ == "__main__":
    deployment.apply()

Then yesterday I updated prefect to version 2.16.3 and the same flow gives the depreciated warning:

08:11:09.880 | WARNING | prefect.deployments - The field 'schedule' in 'Deployment' has been deprecated. It will not be available after Sep 2024. Define schedules in the `schedules` list instead.

The issues is that it does not create a deployment. Looking in the UI I see nothing is created.

How can I now create a CronSchedule for my deployment using the new method.

Fixed this myself using this thread, https://linen.prefect.io/t/16658372/hi-there-i-noticed-that-the-schedule-option-has-disappeared-

Apparently the import is now:

from prefect.client.schemas.schedules import CronSchedule

and the schedule becomes a schedules list

 schedules=[CronSchedule(cron="0 0 * * *", timezone="America/Chicago")]

Might just be me but I find these changes very difficult to find (release notes?) and not very well documented.

1 Like