Nguyen Hoang Nguyen

03/06/2020, 7:53 AM
Hi right now I want to scheldure a task with a CronClock, but right now the default CronClock of Prefect is in UTC. Is there a way to change it to a specific time zone? The code I try right now is as follow but it does not change the start date of the CronClock (terminal still show UTC)
from prefect.schedules.clocks import CronClock
import pendulum

schedule = Schedule(clocks=[CronClock("40 14 * * *","Asia/Ho_Chi_Minh"))])

Alex Goodman

03/06/2020, 1:18 PM
what version of prefect core are you on? I tried out your example without issue:
        clocks=[CronClock("17 20 * * *","Asia/Ho_Chi_Minh"))]
[2020-03-06 13:16:30,276] INFO - prefect.Flow: long-sleep | Waiting for next scheduled run
 at 2020-03-06T20:17:00+07:00
[2020-03-06 13:17:00,005] INFO - prefect.FlowRunner | Beginning Flow run for 'long-sleep'
(specifically the start date is the correct timezone of +7 hours offset)

Nguyen Hoang Nguyen

03/10/2020, 3:16 AM
hmm im running on 0.9.5 version. Still does not work, the original clock is still in UTC.
I have tried the example code from the documentation
import prefect
from prefect import task, Flow
from datetime import timedelta
from prefect.schedules.clocks import CronClock
import pendulum
def say_hello():
    print("Hello, world!")

daily_schedule = prefect.schedules.Schedule(clocks=[CronClock("17 20 * * *","Asia/Ho_Chi_Minh"))])

with Flow("Hello", daily_schedule) as flow:
it returns this while my execute local time is 10:20 AM. So the clock is still UTC
[2020-03-10 03:19:33,565] INFO - prefect.Flow: Hello | Waiting for next scheduled run at 2020-03-10T20:17:00+07:00
you can see the screenshot below if you want