schedr.outcomes¶
Outcomes: which kind of success a task had, and what routes on it (.on(...)).
Every task has an outcome enum (see archive/PROJECT.md, Task results and outcomes):
DefaultOutcome(SUCCESS) for an ordinary return type, an empty task and a command withoutoutcomes=;a declared
Outcomeenum:def check() -> Check(the member is the outcome, the outputNone), orCommandOperator(..., outcomes=Check)(the members’ values are exit codes);an implicit one from an outcome union: a return type that is a union of two or more dataclasses, Pydantic models and
None(-> Rows | Unavailable), one outcome per class, named after it ("None"forNone).
In the backend an outcome is a name; the classes and enums exist only here.
- class schedr.outcomes.Data¶
Bases:
objectThe base of outcome classes: a subclass is a dataclass, and type checkers see
.on.class Rows(Data, frozen=True): rows: list[Row]is what@dataclass(frozen=True)would make, with nothing else at run time. Type checkers read a call of a task returningRows | Unavailableas that union, so.on(Rows)(typedRows) and>>must come from the class:Datadeclares them for type checkers only. Dataclass options are class keywords (frozen,eq,order,kw_only,unsafe_hash,repr);slotsisn’t one (it makes a new class).Ordinary data (not an outcome) stays a plain
@dataclass.
- class schedr.outcomes.DefaultOutcome(*values)¶
Bases:
OutcomeThe outcome of a task without outcomes of its own.
- class schedr.outcomes.Done(*args, **kwargs)¶
Bases:
ProtocolWhat a call of a task without data gives, for type checkers: something to order.
A task returning
None, an edge on anOutcomemember (check().on(Check.CHANGED)) and.on(None)are typedDone:>>orders them, nothing can be passed.
- class schedr.outcomes.Outcome(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
IntEnumThe base of a task’s declared outcomes: subclass it, one member per outcome.
For a
commandtask each member’s value is the exit code meaning it (a declared code is a success, any other a failure); for a Python task returning a member the values are ignored. One enum can serve both, so a check can move between Bash and Python without changing any edge:class Check(Outcome): CHANGED = 0 UNCHANGED = 3
In a DAG body, a call of a task returning one is typed as the enum (its output is
None):check().on(Check.CHANGED) >> notify,react(check().outcome).
- class schedr.outcomes.RunIf(*values)¶
Bases:
StrEnumWhen a task runs, from its upstream edges (its trigger rule).
An edge not taken (an
.on(...)whose outcome didn’t happen, or a skipped upstream task) counts as skipped.- NONE_FAILED = 'none_failed'¶
skipped when all were skipped; a reference whose edge wasn’t taken passes
None.- Type:
Every edge that wasn’t skipped succeeded and at least one did (the default)
- ALL_SUCCEEDED = 'all_succeeded'¶
skipped when one was skipped, so its data is never
None.- Type:
Every edge succeeded
- exception schedr.outcomes.TypingHint¶
Bases:
UserWarningA DAG that runs as written, but that type checkers will read wrongly.
E.g. an outcome class deriving from neither
schedr.Datanorschedr.pydantic.Model:.on(Cls)works when the DAG runs, but type checkers reject it (seeschedr.on).schedr dags checkprints these; pytest lists them in its warnings summary.