yggdrasil.enums.state¶
state ¶
Backend-agnostic execution + order state enum.
PARITY: ported to JS/TS at packages/yggdrasil/enums/state.ts — keep in sync.
Every async-execution surface in yggdrasil — Databricks SQL warehouse
statements, Spark jobs, Mongo / Postgres commands, FastAPI long-running
tasks — and every order-style lifecycle (FIX-protocol order flows,
trading-venue acknowledgements, transaction state machines) reports
its progress through one shared vocabulary. Centralizing it on
:class:State lets :class:StatementResult and any order resource
derive done / failed / started from a single typed enum
and keeps the per-backend status mapping in one place.
Lifecycle ordering (low → high integer codes):
- :attr:
IDLE— built locally, no submission attempt yet. - :attr:
QUEUED— prepared, sitting in a submission queue. - :attr:
PENDING— handed to a backend / venue, awaiting acknowledgement. - :attr:
ACCEPTED— acknowledged / accepted but not yet executing. - :attr:
RUNNING— actively executing (FIX: working / new). - :attr:
PARTIAL— partially filled / streaming results, still active. - :attr:
SUCCEEDED— terminal, fully filled / completed. - :attr:
REJECTED— terminal, rejected at submission or accept time. - :attr:
FAILED— terminal, errored mid-execution. - :attr:
CANCELED— terminal, user or system abort. - :attr:
EXPIRED— terminal, TTL / done-for-day elapsed.
Parsing accepts:
- :class:
State(returned as-is); - a string alias —
"queued","pending","running","succeeded","completed","failed","canceled","closed", … (full alias table below). Mixed case, hyphens, underscores, and spaces all normalize; - an integer code matching a member's value (round-trips with
int); - an SDK enum that exposes
.name/.valuewhose token matches an alias (DatabricksStatementState.SUCCEEDED→State.SUCCEEDED); None— returns default if supplied, else :data:State.IDLE.
State ¶
Bases: IntEnum
Unified execution state for async statement / job results.
Use :meth:from_ to normalize backend-specific tokens, and the
is_* predicates to derive done / failed / started
without re-implementing the membership sets per backend.
is_queued
property
¶
True for :attr:QUEUED — prepared, sitting in a submission queue.
is_accepted
property
¶
True for :attr:ACCEPTED — acknowledged but not yet running.
is_started
property
¶
True for anything from :attr:RUNNING onward.
Mirrors :attr:StatementResult.started: once the backend has
actually started executing, is_started flips and stays
True through every terminal state. :attr:ACCEPTED is
not started — the venue holds the order, no execution yet.
is_active
property
¶
True for non-terminal states with backend awareness.
Covers :attr:QUEUED through :attr:PARTIAL — anything the
caller can reasonably wait on. :attr:IDLE is excluded
(nothing has been submitted yet) and every terminal state is
excluded (no more transitions).
is_done
property
¶
True for terminal states (:attr:SUCCEEDED, :attr:REJECTED,
:attr:FAILED, :attr:CANCELED, :attr:EXPIRED) — no more
transitions expected.
is_failed
property
¶
True for :attr:REJECTED / :attr:FAILED / :attr:CANCELED /
:attr:EXPIRED.
Every non-success terminal state counts as failed because each
one means "the caller asked for a result and didn't get one":
cancellation, rejection, mid-run error, or TTL expiry all leave
the operation incomplete from the caller's view, and the
per-backend raise_for_status raises on each.
from_
classmethod
¶
Coerce any Python value into a :class:State.
See module docstring for the accepted shapes. default
swallows unknown / unparseable input; without it, unknown
tokens raise :class:ValueError and unsupported types raise
:class:TypeError.
is_valid
classmethod
¶
Return True when :meth:from_ would succeed for value.