Schedule
Build a schedule object for batch/workflow jobs using friendly fields.
Examples:
schedule = Schedule(at_hours=[0])
schedule = Schedule(at_minutes=[0, 30], weekdays=["Mon", "Wed", "Fri"])
You can either provide a raw cron_expression or use the human-readable helper parameters (which are compiled into cron syntax automatically).
Parameters:
-
(cron_expressionstr, default:'') –A raw cron string (e.g.
"0 */2 * * *"). If provided alongside helper parameters, the helpers take precedence. -
(at_minuteslist[int] | None, default:None) –Specific minutes past the hour to run (e.g.
[0, 30]for":00"and":30"). -
(every_minuteint | None, default:None) –Run every N minutes (e.g.
5for every 5 minutes). -
(at_hourslist[int] | None, default:None) –Specific hours of the day to run (0 -- 23).
-
(every_hourint | None, default:None) –Run every N hours.
-
(weekdayslist[str] | None, default:None) –Days of the week to run (e.g.
["mon", "wed", "fri"]). -
(day_of_monthint | None, default:None) –Day of the month to run (1 -- 31).
-
(in_monthlist[str] | None, default:None) –Months to run in (e.g.
["jan", "apr", "jul", "oct"]). -
(every_monthint | None, default:None) –Run every N months.
-
(timezonestr | None, default:None) –IANA timezone name (e.g.
"America/New_York"). -
(run_after_job_uuidstr | None, default:None) –UUID of a job that must complete before this schedule triggers.
-
(run_after_job_namestr | None, default:None) –Name of a job that must complete before this schedule triggers.
-
(run_after_job_conditionstr | None, default:None) –Required completion status of the predecessor job (e.g.
"success").
Example
from datatailr import Schedule
# Every weekday at 08:00 and 16:00 UTC
s = Schedule(at_hours=[8, 16], weekdays=["mon","tue","wed","thu","fri"])
get_cron_string
Return the compiled cron string.
Returns:
-
str–Cron string (str).
Examples:
>>> Schedule(
... at_minutes=[0, 15, 30, 45],
... at_hours=[0, 12],
... weekdays=["Mon", "Wed", "Fri"],
... day_of_month=15,
... in_month=["Jan", "Jul"],
... ).get_cron_string()
'0 0,15,30,45 0,12 15 1,7 1,3,5'