[Core feature] Add timezone to CronSchedule
Motivation: Why do you think this is important?
There are instances where some flows are expected to launch at a time anchored to a specific time zone. The CronSchedule has an offset parameter, however this is a fixed value. During daylight savings time adjustments, a discrepancy is introduced unless the offset parameter is updated.
Goal: What should the final outcome look like, ideally?
Addition of another optional parameter accepting an IANA timezone like Americas/Los_Angeles as used by Python's tzinfo. The Flyte scheduler should use this timezone as an override to any application interpretation of the cron schedule.
Describe alternatives you've considered
We tried the offset parameter and just relying on UTC scheduling, but the DST shifts will cause issues down the road.
Propose: Link/Inline OR Additional context
No response
Are you sure this issue hasn't been raised already?
- [X] Yes
Have you read the Code of Conduct?
- [X] Yes
Thank you for opening your first issue here! 🛠
In principle, this could be achieved in the case of the Flyte Native Scheduler. Under the covers we use https://github.com/robfig/cron, which is able to parse the expression CRON_TZ=<time-zone>, as described in the docs:
CRON_TZ is now the recommended way to specify the timezone of a single schedule, which is sanctioned by the specification. The legacy "TZ=" prefix will continue to be supported since it is unambiguous and easy to do so
Unfortunately, that convention is not implemented in the python library we use to validate cron expressions, https://github.com/kiorky/croniter, which complicates matters.
We'd also have to update the parsing of the cron expression in flyteconsole, as that uses a library that doesn't implement the CRON_TZ=<time-zone> convention either.
+1 to feature
Hi @eapolinario! I did some digging and I think I've scoped out the changes into three MRs that need to happen. Would love to hear your feedback before trying this out.
- Update Proto Definition in flyte
- Add string field for IANA timezone code.
- Update database API to include tz code.
- Add timezone to cron creation code.
- Update flytekit to create schedule
- Update schedule.py to include to include tz in the API and check if timezone is valid using
pytz.all_timezones.
- Update FlyteConsole parsing code
- Cron Parser has timezone support: https://github.com/harrisiirak/cron-parser?tab=readme-ov-file#timezone-support
- Update code to parse other timezones.