Skip to content

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 / .value whose token matches an alias (Databricks StatementState.SUCCEEDEDState.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_idle property

is_idle: bool

True for :attr:IDLE — built locally, not submitted yet.

is_queued property

is_queued: bool

True for :attr:QUEUED — prepared, sitting in a submission queue.

is_pending property

is_pending: bool

True for :attr:PENDING — handed to a backend, awaiting ack.

is_accepted property

is_accepted: bool

True for :attr:ACCEPTED — acknowledged but not yet running.

is_running property

is_running: bool

True for :attr:RUNNING — actively executing.

is_partial property

is_partial: bool

True for :attr:PARTIAL — partially filled, still active.

is_started property

is_started: bool

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

is_active: bool

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

is_done: bool

True for terminal states (:attr:SUCCEEDED, :attr:REJECTED, :attr:FAILED, :attr:CANCELED, :attr:EXPIRED) — no more transitions expected.

is_failed property

is_failed: bool

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.

is_succeeded property

is_succeeded: bool

True for :attr:SUCCEEDED — terminal with a full result.

is_rejected property

is_rejected: bool

True for :attr:REJECTED — refused at submission / accept.

is_canceled property

is_canceled: bool

True for :attr:CANCELED.

is_expired property

is_expired: bool

True for :attr:EXPIRED — TTL / day-rollover terminal.

from_ classmethod

from_(value: Any, *, default: Any = ...) -> 'State'

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

is_valid(value: Any) -> bool

Return True when :meth:from_ would succeed for value.