schedr._model.dag¶
A DAG in DAG JSON: what the runner sends after parsing a DAG file.
Mirrors schedr-model (dag.rs).
- class schedr._model.dag.DagLocation(root, path)¶
Bases:
objectWhere a DAG is defined: a DAG root and a file path relative to it.
- Parameters:
root (str)
path (str)
- root¶
The root’s name.
- Type:
str
- path¶
The file’s path relative to the root, with
/separators.- Type:
str
- to_json()¶
The location as DAG JSON.
- Returns:
{"root": ..., "path": ...}.- Return type:
dict[str, Any]
- class schedr._model.dag.EdgeKind(*values)¶
Bases:
StrEnumWhy one task depends on another.
- DATA = 'data'¶
The downstream task takes the upstream task’s output.
- ORDER = 'order'¶
An order-only dependency (
>>).
- REQUIREMENT = 'requirement'¶
it can stop the user, never make it run.
- Type:
A resource’s setup to a user
- SELECTION = 'selection'¶
taken when the branch chose the downstream task.
- Type:
From a
@branchtask
- class schedr._model.dag.Edge(from_, to, kind, on=())¶
Bases:
objectA dependency:
toruns afterfrom_.- Parameters:
from_ (str)
to (str)
kind (EdgeKind)
on (tuple[str, ...])
- from_¶
The upstream task’s ID.
- Type:
str
- to¶
The downstream task’s ID.
- Type:
str
- kind¶
Why the dependency exists.
- on¶
The upstream outcomes it is taken on (
.on(...)); empty for any.- Type:
tuple[str, …]
- to_json()¶
The edge as DAG JSON.
- Returns:
{"from": ..., "to": ..., "kind": ..., "on": [...]}(ononly if not empty).- Return type:
dict[str, Any]
- class schedr._model.dag.Group(id, parent=None)¶
Bases:
objectA group of tasks (decision 64): a name for some of a DAG’s tasks, for the UI and API.
- Parameters:
id (str)
parent (str | None)
- id¶
The group’s ID (
load,load.euwhen nested).- Type:
str
- parent¶
The group it is nested in, if any.
- Type:
str | None
- to_json()¶
The group as DAG JSON.
- Returns:
{"id": ...}, with"parent"when nested.- Return type:
dict[str, Any]
- class schedr._model.dag.DagParams(type_desc, schema, defaults=<factory>)¶
Bases:
objectThe run parameters a DAG takes (
Dag(params=...), decision 138).- Parameters:
type_desc (TypeDesc)
schema (Mapping[str, Any])
defaults (Mapping[str, Any])
- type_desc¶
The declared class’s type: a dataclass or a Pydantic model.
- schema¶
A JSON Schema of it, as JSON values (a date as
format: date).- Type:
collections.abc.Mapping[str, Any]
- defaults¶
The fields’ defaults, as JSON.
- Type:
collections.abc.Mapping[str, Any]
- to_json()¶
The parameters as DAG JSON.
- Returns:
{"type": ..., "schema": ..., "defaults": ...}(defaultsonly if not empty).- Return type:
dict[str, Any]
- class schedr._model.dag.Resource(setup, cleanup, users=(), blocking=True, unschedulable_timeout_ms=None)¶
Bases:
objectA resource: one thing of two parts, each a task of the DAG (decision 259).
- Parameters:
setup (str)
cleanup (str)
users (Sequence[str])
blocking (bool)
unschedulable_timeout_ms (int | None)
- setup¶
The task that creates it; its ID is the resource’s.
- Type:
str
- cleanup¶
The task that undoes it, once every user is done.
- Type:
str
- users¶
The tasks that need it, in the order of the edges.
- Type:
collections.abc.Sequence[str]
- blocking¶
Whether what follows its group waits for its cleanup (decision 266).
- Type:
bool
- unschedulable_timeout_ms¶
How long a user may wait for a worker before it fails (decision 273);
None: no limit.- Type:
int | None
- to_json()¶
The resource as DAG JSON.
- Returns:
{"setup": ..., "cleanup": ..., "users": [...]}, with"blocking": falseand"unschedulable_timeout_ms"when set.- Return type:
dict[str, Any]
- class schedr._model.dag.Dag(id, location, tasks=(), edges=(), trigger=<factory>, initial_since=None, max_active_runs=1, max_active_tasks=None, description=None, tags=(), produced_by=<factory>, groups=(), params=None, resources=(), notify=())¶
Bases:
objectA DAG: its identity, trigger, tasks and dependencies.
- Parameters:
id (str)
location (DagLocation)
tasks (Sequence[Task])
edges (Sequence[Edge])
trigger (Trigger)
initial_since (datetime | None)
max_active_runs (int | None)
max_active_tasks (int | None)
description (str | None)
tags (Sequence[str])
produced_by (SchedrVersion)
groups (Sequence[Group])
params (DagParams | None)
resources (Sequence[Resource])
notify (Sequence[NotifyEntry])
- id¶
The DAG’s ID.
- Type:
str
- location¶
Where it is defined.
- tasks¶
The tasks, in declaration order.
- Type:
collections.abc.Sequence[schedr._model.tasks.Task]
- edges¶
The dependencies between them.
- Type:
collections.abc.Sequence[schedr._model.dag.Edge]
- trigger¶
What starts its runs (besides people and other DAGs).
- initial_since¶
sinceof the run on the DAG’s first fire time.- Type:
datetime.datetime | None
- max_active_runs¶
At most this many runs at a time;
Nonefor no limit.- Type:
int | None
- max_active_tasks¶
At most this many of its tasks running at once, across all its runs;
Nonefor no limit.- Type:
int | None
- description¶
Shown in the UI.
- Type:
str | None
- tags¶
Shown in the UI and used for filtering.
- Type:
collections.abc.Sequence[str]
- produced_by¶
The schedr version producing this JSON (the installed one by default).
- groups¶
The task groups, outer before inner.
- Type:
collections.abc.Sequence[schedr._model.dag.Group]
- params¶
The run parameters it takes;
None: none.- Type:
schedr._model.dag.DagParams | None
- resources¶
Its resources.
- Type:
collections.abc.Sequence[schedr._model.dag.Resource]
- notify¶
The channels it notifies, and of which events.
- Type:
collections.abc.Sequence[schedr._model.notify.NotifyEntry]
- to_json()¶
The DAG as DAG JSON.
- Returns:
The document the master stores;
descriptionandtagsonly when set.- Raises:
ValueError – If a timestamp is naive.
- Return type:
dict[str, Any]