You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add timezone support for CRON triggers (#438)
Allow users to specify timezone when setting up CRON triggers to enable
scheduling in local time zones with automatic DST handling.
Changes:
- Add timezone field to CronTrigger and DatabaseTriggers models
- Implement timezone-aware cron scheduling using Python's zoneinfo
- Validate timezone using IANA timezone database
- Update Python SDK to support timezone parameter
- Add comprehensive documentation with examples
- Default to UTC for backward compatibility
The timezone field is optional and defaults to "UTC". All trigger times
are internally stored in UTC while croniter calculations respect the
specified timezone, ensuring correct scheduling across time zones and
DST transitions.
Signed-off-by: Sparsh <sparsh.raj30@gmail.com>
Copy file name to clipboardExpand all lines: docs/docs/exosphere/triggers.md
+30-6Lines changed: 30 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,13 +61,15 @@ Define triggers in your graph template:
61
61
{
62
62
"type": "CRON",
63
63
"value": {
64
-
"expression": "0 9 * * 1-5"
64
+
"expression": "0 9 * * 1-5",
65
+
"timezone": "America/New_York"
65
66
}
66
67
},
67
68
{
68
69
"type": "CRON",
69
70
"value": {
70
-
"expression": "0 0 * * 0"
71
+
"expression": "0 0 * * 0",
72
+
"timezone": "UTC"
71
73
}
72
74
}
73
75
],
@@ -77,6 +79,8 @@ Define triggers in your graph template:
77
79
}
78
80
```
79
81
82
+
**Note:** The `timezone` field is optional and defaults to `"UTC"` if not specified. Use IANA timezone names (e.g., `"America/New_York"`, `"Europe/London"`, `"Asia/Tokyo"`).
1.**Avoid Peak Times**: Schedule resource-intensive workflows during off-peak hours
160
164
2.**Stagger Executions**: If you have multiple graphs, stagger their execution times
161
-
3.**Consider Time Zones**: Cron expressions use server time (UTC by default)
165
+
3.**Consider Time Zones**: Specify the `timezone` parameter to ensure your cron expressions run at the correct local time. If not specified, defaults to UTC.
162
166
4.**Resource Planning**: Ensure your infrastructure can handle scheduled workloads
163
167
164
168
### Error Handling
@@ -191,11 +195,31 @@ result = await state_manager.upsert_graph(
191
195
)
192
196
```
193
197
198
+
## Timezone Support
199
+
200
+
Triggers now support specifying a timezone for cron expressions, allowing you to schedule jobs in your local timezone:
201
+
202
+
```python
203
+
# Schedule a report to run at 9 AM New York time (handles DST automatically)
expression: str=Field(..., description="Cron expression for scheduling automatic graph execution. Uses standard 5-field format: minute hour day-of-month month day-of-week. Example: '0 9 * * 1-5' for weekdays at 9 AM.")
163
+
expression: str=Field(..., description="Cron expression for scheduling automatic graph execution. Uses standard 5-field format: minute hour day-of-month month day-of-week. Example: '0 9 * * 1-5' for weekdays at 9 AM.")
164
+
timezone: str=Field(default="UTC", description="Timezone for the cron expression (e.g., 'America/New_York', 'Europe/London', 'UTC'). Defaults to 'UTC'.")
0 commit comments