https://prefect.io logo
Title
d

Dominik Wagner

08/01/2022, 3:19 PM
Prefect 2.0.1 | Scheduling Hi! šŸ‘‹ I’m trying to figure out how to set up a schedule (not using the UI). Is there a way to do it within the
prefect deployment build…
command? i.e. i have something like this in a bash script:
prefect deployment build flows/dbt_flow.py:dbt_primary_flow \
--name prod_flow \
--tag dbt \
--tag prod \
--tag daily \
-sb gcs/gcs-block \
-ib kubernetes-job/k8s-block
And I’d like to add something like
--schedule "cron/0 7 * * */Europe/Berlin"
If that’s not possible I guess I have to manually edit the deployment.yaml - if that’s the case, can I just put a cron expression in there, or do I need something else? I can’t find any examples in the docs, but maybe I’m just blind? šŸ™ƒ
šŸ‘ 1
āœ… 1
j

Jeff Hale

08/01/2022, 3:40 PM
Right now, you do need to edit it manually in the
deployment.yaml
or the GUI. Here’s how it looks in the yaml file:
schedule:
  interval: 600
  timezone: America/Chicago 

schedule:
  cron: 0 0 * * *
  timezone: America/Chicago

schedule:
  rrule: 'FREQ=WEEKLY;BYDAY=MO,WE,FR;UNTIL=20240730T040000Z'
Note that timezones are optional and RRule is only supported in the deployment YAML file, currently.
d

Dominik Wagner

08/01/2022, 3:43 PM
Okay, thanks @Jeff Hale, I guess the idea is to only ā€œbuildā€ your deployment yaml once, and then update it directly as needed?
j

Jeff Hale

08/01/2022, 3:52 PM
That’s the idea. šŸ™‚
šŸ‘Œ 1
b

Benny Warlick

08/01/2022, 9:33 PM
@Jeff Hale can you explain this? Every time the code changes I need to run "prefect deployment build" again to copy the new code to the storage block. And then I need to start over editing the deployment yaml, right? Am I missing something or is there a way around this?
I had put "prefect deployment build" in my CI process so that the new code would automatically be copied to the storage block. But that doesn't work if I need to make edits to the deployment yaml, for example to set a schedule.
j

Jeff Hale

08/01/2022, 10:35 PM
I believe versioning for deployment.yaml files is coming very soon - probably a matter of days. Would that help?
b

Benny Warlick

08/01/2022, 10:53 PM
Yes, thanks that sounds helpful. In the meantime I'll just redirect the new yamls into a temp file.
d

Dominik Wagner

08/02/2022, 6:54 AM
I guess an alternative is to upload the files to the storage block yourself during CI, and skip the
prefect deployment build
step all together?
b

Benny Warlick

08/02/2022, 2:10 PM
Yes, not sure what the best practice is here. We have multiple flows and I think its best to build the upload into automated CI actions to be sure the flows in storage accurately reflect the current code.