schedr._model.trigger¶
A DAG’s trigger in DAG JSON (schedr-model, trigger.rs).
- class schedr._model.trigger.NoTrigger¶
Bases:
objectNothing starts runs: manual runs only.
- to_json()¶
The trigger as DAG JSON.
- Returns:
{"kind": "none"}.- Return type:
dict[str, Any]
- class schedr._model.trigger.CronTrigger(expression, timezone='UTC', catchup=False, start=None, end=None)¶
Bases:
objectA cron expression evaluated in a time zone.
- Parameters:
expression (str)
timezone (str)
catchup (bool)
start (datetime | None)
end (datetime | None)
- expression¶
5 or 6 fields, or a preset such as
@daily.- Type:
str
- timezone¶
An IANA time zone name, e.g.
Europe/Warsaw.- Type:
str
- catchup¶
Whether missed fire times get runs in order.
- Type:
bool
- start¶
The first run is for the first fire time at or after it (aware).
- Type:
datetime.datetime | None
- end¶
The last run is for the last fire time at or before it (aware).
- Type:
datetime.datetime | None
- to_json()¶
The trigger as DAG JSON.
- Returns:
{"kind": "cron", "expression": ..., "timezone": ..., "catchup": ...}withstartandend(UTC, or null).- Return type:
dict[str, Any]
- class schedr._model.trigger.EveryTrigger(interval_ms, catchup=False, start=None, end=None)¶
Bases:
objectA fixed interval measured in real time (UTC).
- Parameters:
interval_ms (int)
catchup (bool)
start (datetime | None)
end (datetime | None)
- interval_ms¶
The interval in milliseconds; must be positive.
- Type:
int
- catchup¶
Whether missed fire times get runs in order.
- 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); aware.
- Type:
datetime.datetime | None
- end¶
The last run is for the last fire time at or before it (aware).
- Type:
datetime.datetime | None
- to_json()¶
The trigger as DAG JSON.
- Returns:
{"kind": "every", "interval_ms": ..., "catchup": ...}withstartandend(UTC, or null).- Return type:
dict[str, Any]
- class schedr._model.trigger.OnceTrigger(at)¶
Bases:
objectA single fire time.
- Parameters:
at (datetime)
- at¶
The fire time (aware).
- Type:
datetime.datetime
- to_json()¶
The trigger as DAG JSON.
- Returns:
{"kind": "once", "at": ...}in UTC.- Return type:
dict[str, Any]
- class schedr._model.trigger.ChainedTrigger(by=None)¶
Bases:
objectOnly other DAGs’
TriggerDagOperatortasks start its runs (decision 398).- Parameters:
by (tuple[str, ...] | None)
- by¶
The DAGs whose operators may start it;
None: any DAG.- Type:
tuple[str, …] | None
- to_json()¶
The trigger as DAG JSON.
- Returns:
{"kind": "chained"}, withbywhen it names DAGs.- Return type:
dict[str, Any]
- class schedr._model.trigger.EventTrigger(task, restart_if_idle_ms=None, start=None, end=None, run_retries=None)¶
Bases:
objectA
@triggerfunction: its events start runs.- Parameters:
task (Task)
restart_if_idle_ms (int | None)
start (datetime | None)
end (datetime | None)
run_retries (int | None)
- task¶
Its function, as a task of kind
sensorthat isn’t in the graph.- Type:
- restart_if_idle_ms¶
Started again from its bookmark when no event came for this long.
- Type:
int | None
- start¶
It runs from this moment on (aware).
- Type:
datetime.datetime | None
- end¶
It stops at this moment (aware).
- Type:
datetime.datetime | None
- run_retries¶
@trigger(wait_for=..., run_retries=N): a run its function raised on so many times in a row is passed (decision 353);None: untilschedr triggers skip.- Type:
int | None
- to_json()¶
The trigger as DAG JSON.
- Returns:
{"kind": "event", "task": {...}, "start": ..., "end": ...}, andrestart_if_idle_mswhen it is set.- Return type:
dict[str, Any]
- class schedr._model.trigger.RunOfTrigger(dag, task=None, lag_ms=None)¶
Bases:
objecttrigger=RunOf(...): a run per run of another DAG that succeeded (decision 353).- Parameters:
dag (str)
task (str | None)
lag_ms (int | None)
- dag¶
That DAG.
- Type:
str
- task¶
Its task;
None: the whole run.- Type:
str | None
- lag_ms¶
The new run is planned this long after that one;
None: when it is seen.- Type:
int | None
- to_json()¶
The trigger as DAG JSON.
- Returns:
{"kind": "run_of", "run_of": {"dag": ...}}, with what is set.- Return type:
dict[str, Any]
- class schedr._model.trigger.EventNamedTrigger(name)¶
Bases:
objecttrigger=EventNamed(...): a run per key of the events of a name posted.Decision 354: the events are posted through the API.
- Parameters:
name (str)
- name¶
The events’ name.
- Type:
str
- to_json()¶
The trigger as DAG JSON.
- Returns:
{"kind": "event_named", "event": {"name": ...}}.- Return type:
dict[str, Any]
- type schedr._model.trigger.Trigger = NoTrigger | CronTrigger | EveryTrigger | OnceTrigger | ChainedTrigger | EventTrigger | RunOfTrigger | EventNamedTrigger¶
Any trigger.