How do I get `CronSchedule("0 11 * * *")` to fire ...
# prefect-community
j
How do I get
CronSchedule("0 11 * * *")
to fire at 11 and not 12?
🙌 1
a
By default, CRON Schedule is in UTC.
Copy code
from prefect.schedules import CronSchedule

sched = CronSchedule(cron="0 11 * * *")
print(sched.next(10))
Here is how you can attach your timezone:
Copy code
from prefect.schedules import CronSchedule
import pendulum

sched = CronSchedule(
    cron="0 11 * * *",
    start_date=pendulum.datetime(2022, 4, 25, 0, 0, tz="Europe/London"),
)
print(sched.next(10))
Printing the next schedules
sched.next(10)
can help make sure your schedule is configured correctly
j
Ahhh OK so it infers the TZ from the start date!! Thanks! Could it be an arg to the
CronSchedule
perhaps?
a
Exactly! And you're spot on that it could! The syntax in Prefect 2.0 is exactly that:
Copy code
schedule=CronSchedule(cron="0 11 * * *", timezone="Europe/Berlin"),
🙌 1
j
@Anna Geller on the 2.0 point - how painful is it going to be for me to move to 2.0 given I have built everything out for 1.0 - is there gonna be a nice smooth transition that isn't gonna require huge infra changes?
Or am I gonna end up in a world where I am stuck with 1.0 cos the migration is painful and then all support for 1.0 ends?
The model of k8s and jobs per flow is really not something I want to have to change for example
a
We'll do our best to support you with migration. There is already a special tag on Discourse called migration-guide, and if you are an existing customer, our CS team provides support, too (cs@prefect.io). And of course, there will be a Migration Guide docs section with more details.
🙌 1
About Kubernetes - there is
KubernetesFlowRunner
which is equivalent to
KubernetesRun
run configuration.
🙌 1
j
Does the idea of an Agent disappear? How is that link between prefect cloud infra and private infra maintained in 2.0?
a
Agents are still there but they are not tied to a specific infrastructure - e.g. there is no need for a Kubernetes agent. The same agent can deploy flow runs as Docker containers or Kubernetes jobs, depending on your flow runner configuration. Check this Discourse topic for more info
🙌 1
was it typed by accident @Olivér Atanaszov? 😄
o
yes, removed now 🙂
👍 1
j
Is there a way to set Cron Time zone at an agent level like US/Eastern via maybe an environment variable so that I do not have to specify it for every Cron schdule? I guess alternatively, I could wrap CronSchedule using functools to provide additional args to make it EST.
a
in Prefect 2.0 you can even wrap it in some custom function and supply it to your
DeploymentSpec