schedr.triggers

Triggers: what starts runs of a DAG, Dag(trigger=...).

Cron fires at the times a cron expression describes, in a time zone (default UTC); Every fires at a fixed interval measured in real time; Once fires once, at a given moment. A DAG without a trigger (trigger=None) has manual runs only. The others share Trigger too: a @trigger function called with its arguments (schedr.event_triggers) starts a run per event, RunOf (schedr.run_of) one per run of another DAG that succeeds. See archive/PROJECT.md, Native API.

schedr.triggers.PRESETS = frozenset({'@annually', '@daily', '@hourly', '@midnight', '@monthly', '@weekly', '@yearly'})

The cron presets accepted instead of an expression.

schedr.triggers.UNSET = _Unset.UNSET

An option override leaves as it is.

class schedr.triggers.Trigger

Bases: object

The base of the trigger classes; not for subclassing outside schedr.

to_model()

The trigger in DAG JSON.

Raises:

NotImplementedError – Always; every trigger class defines it.

Return type:

Trigger

schedr.triggers.Moment = datetime.datetime | datetime.date | str | None

aware datetime, or a naive one / a date / an ISO string, read in the trigger’s time zone.

Type:

A start / end

class schedr.triggers.Cron(expression, tz='UTC', catchup=False, start=None, end=None)

Bases: Trigger

A cron trigger, e.g. Cron("0 3 * * *", tz="Europe/Warsaw").

Parameters:
  • expression (str)

  • tz (str)

  • catchup (bool)

  • start (datetime | date | str | None)

  • end (datetime | date | str | None)

expression

5 fields (minute, hour, day of month, month, day of week), 6 with seconds first, or a preset such as @daily.

Type:

str

tz

The IANA time zone the expression is evaluated in, and naive start / end are read in.

Type:

str

catchup

Whether missed fire times get runs in order (default: only the most recent).

Type:

bool

start

The first run is for the first fire time at or after it; without it, from when the master first stored the DAG.

Type:

datetime.datetime | datetime.date | str | None

end

The last run is for the last fire time at or before it.

Type:

datetime.datetime | datetime.date | str | None

override(*, expression=_Unset.UNSET, tz=_Unset.UNSET, catchup=_Unset.UNSET, start=_Unset.UNSET, end=_Unset.UNSET)

The same trigger with some options changed, e.g. DAILY.override(start=...).

Returns:

A new trigger.

Raises:

ValueError – For a value the class rejects.

Parameters:
  • expression (str | _Unset)

  • tz (str | _Unset)

  • catchup (bool | _Unset)

  • start (datetime | date | str | None | _Unset)

  • end (datetime | date | str | None | _Unset)

Return type:

Self

to_model()

The trigger in DAG JSON.

Returns:

The cron trigger.

Return type:

CronTrigger

class schedr.triggers.Every(interval, catchup=False, start=None, end=None)

Bases: Trigger

A fixed interval in real time, e.g. Every(timedelta(hours=1)).

Daylight-saving changes don’t affect it.

Parameters:
  • interval (timedelta)

  • catchup (bool)

  • start (datetime | date | str | None)

  • end (datetime | date | str | None)

interval

The time between runs; positive, a whole number of milliseconds.

Type:

datetime.timedelta

catchup

Whether missed fire times get runs in order (default: only the most recent).

Type:

bool

start

The first run is for the first fire time at or after it, and fire times are whole intervals from it (from the Unix epoch without it, so timedelta(hours=1) fires on the hour); naive values are UTC.

Type:

datetime.datetime | datetime.date | str | None

end

The last run is for the last fire time at or before it.

Type:

datetime.datetime | datetime.date | str | None

override(*, interval=_Unset.UNSET, catchup=_Unset.UNSET, start=_Unset.UNSET, end=_Unset.UNSET)

The same trigger with some options changed, e.g. .override(end=...).

Returns:

A new trigger.

Raises:

ValueError – For a value the class rejects.

Parameters:
  • interval (timedelta | _Unset)

  • catchup (bool | _Unset)

  • start (datetime | date | str | None | _Unset)

  • end (datetime | date | str | None | _Unset)

Return type:

Self

to_model()

The trigger in DAG JSON.

Returns:

The interval trigger.

Return type:

EveryTrigger

class schedr.triggers.Once(at, tz='UTC')

Bases: Trigger

A single fire time, e.g. Once("2026-12-24T23:00", tz="Europe/Warsaw").

The way to run a DAG once at a future time: an ordinary trigger, so end and pausing work as for any other. It has no previous fire time, so a DAG whose tasks use dag_ctx.run.since must set initial_since.

Parameters:
  • at (datetime | date | str)

  • tz (str)

at

The fire time: an aware datetime, or a naive one / a date / an ISO string, read in tz.

Type:

datetime.datetime | datetime.date | str

tz

The IANA time zone of a naive at (and of the DAG’s naive initial_since).

Type:

str

override(*, at=_Unset.UNSET, tz=_Unset.UNSET)

The same trigger with some options changed.

Returns:

A new trigger.

Raises:

ValueError – For a value the class rejects.

Parameters:
  • at (datetime | date | str | _Unset)

  • tz (str | _Unset)

Return type:

Self

to_model()

The trigger in DAG JSON.

Returns:

The single fire time.

Return type:

OnceTrigger

schedr.triggers.HOURLY = Cron(expression='@hourly', tz='UTC', catchup=False, start=None, end=None)

Every hour, on the hour (UTC).

schedr.triggers.DAILY = Cron(expression='@daily', tz='UTC', catchup=False, start=None, end=None)

Every day at midnight (UTC).

schedr.triggers.WEEKLY = Cron(expression='@weekly', tz='UTC', catchup=False, start=None, end=None)

Every Sunday at midnight (UTC).

schedr.triggers.MONTHLY = Cron(expression='@monthly', tz='UTC', catchup=False, start=None, end=None)

The first day of every month at midnight (UTC).

schedr.triggers.YEARLY = Cron(expression='@yearly', tz='UTC', catchup=False, start=None, end=None)

January 1st at midnight (UTC).