Skip to content

Schedule

Build a schedule object for batch/workflow jobs using friendly fields.

Parameters:

Name Type Description Default
cron_expression str

Raw cron expression to use (string).

''
at_minutes list[int] | None

Specific minutes within the hour, e.g. [0, 30].

None
every_minute int | None

Run every N minutes.

None
at_hours list[int] | None

Specific hours within the day, e.g. [0, 12].

None
every_hour int | None

Run every N hours.

None
weekdays list[str] | None

Weekdays by name, e.g. ["Mon", "Wed", "Fri"].

None
day_of_month int | None

Day of the month (1-31).

None
in_month list[str] | None

Months by name, e.g. ["Jan", "Jul"].

None
every_month int | None

Run every N months.

None
timezone str | None

Time zone name, e.g. "UTC".

None
run_after_job_uuid str | None

Job UUID to run after.

None
run_after_job_name str | None

Job name to run after.

None
run_after_job_condition str | None

Condition for dependency, e.g. "on failure".

None

Examples:

schedule = Schedule(at_hours=[0])
schedule = Schedule(at_minutes=[0, 30], weekdays=["Mon", "Wed", "Fri"])

__init__(cron_expression='', at_minutes=None, every_minute=None, at_hours=None, every_hour=None, weekdays=None, day_of_month=None, in_month=None, every_month=None, timezone=None, run_after_job_uuid=None, run_after_job_name=None, run_after_job_condition=None)

Initialize a Schedule.

You can either provide a raw cron_expression or use the human-readable helper parameters (which are compiled into cron syntax automatically).

Parameters:

Name Type Description Default
cron_expression str

A raw cron string (e.g. "0 */2 * * *"). If provided alongside helper parameters, the helpers take precedence.

''
at_minutes list[int] | None

Specific minutes past the hour to run (e.g. [0, 30] for ":00" and ":30").

None
every_minute int | None

Run every N minutes (e.g. 5 for every 5 minutes).

None
at_hours list[int] | None

Specific hours of the day to run (0 -- 23).

None
every_hour int | None

Run every N hours.

None
weekdays list[str] | None

Days of the week to run (e.g. ["mon", "wed", "fri"]).

None
day_of_month int | None

Day of the month to run (1 -- 31).

None
in_month list[str] | None

Months to run in (e.g. ["jan", "apr", "jul", "oct"]).

None
every_month int | None

Run every N months.

None
timezone str | None

IANA timezone name (e.g. "America/New_York").

None
run_after_job_uuid str | None

UUID of a job that must complete before this schedule triggers.

None
run_after_job_name str | None

Name of a job that must complete before this schedule triggers.

None
run_after_job_condition str | None

Required completion status of the predecessor job (e.g. "success").

None
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:

Type Description
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'