Prefect 2.0.1 | Scheduling Hi! :wave: I’m trying ...
# prefect-community
d
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:
Copy code
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
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:
Copy code
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
Okay, thanks @Jeff Hale, I guess the idea is to only “build” your deployment yaml once, and then update it directly as needed?
j
That’s the idea. 🙂
👌 1
b
@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
I believe versioning for deployment.yaml files is coming very soon - probably a matter of days. Would that help?
b
Yes, thanks that sounds helpful. In the meantime I'll just redirect the new yamls into a temp file.
d
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
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.