ractogateway.celery._models

Pydantic models for the Celery task-queue subsystem.

class ractogateway.celery._models.TaskStatus(*values)[source]

Bases: str, Enum

Lifecycle state of a Celery task.

Maps directly to Celery’s native task states so you can compare them without importing Celery’s own constants.

PENDING = 'pending'
STARTED = 'started'
SUCCESS = 'success'
FAILURE = 'failure'
RETRY = 'retry'
REVOKED = 'revoked'
class ractogateway.celery._models.TaskResult(**data)[source]

Bases: BaseModel

Unified result returned by wait() and get_result().

Parameters:
  • task_id (str) – The Celery task UUID.

  • status (TaskStatus) – Current TaskStatus.

  • result (Any | None) –

    Deserialised task output on success:

    • For generate() — a dict matching LLMResponse.model_dump()`.

    • For ingest_document() — a list of Chunk.model_dump()` dicts.

  • error (str | None) – Exception message string on failure; None on success.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

task_id: str
status: TaskStatus
result: Any | None
error: str | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property ok: bool

True when the task succeeded and produced a result.

class ractogateway.celery._models.RetryConfig(**data)[source]

Bases: BaseModel

Exponential-backoff retry policy for RactoCeleryWorker tasks.

The backoff delay for attempt n (0-based) is:

delay = min(initial_delay_s * backoff_factor ** n, max_delay_s)

With the defaults this gives: 2 s → 4 s → 8 s (then stops at max_retries=3).

Parameters:
  • max_retries (int) – Maximum number of retry attempts after the first failure. 0 disables retries entirely.

  • initial_delay_s (float) – Countdown (seconds) before the first retry.

  • backoff_factor (float) – Multiplier applied on each successive retry. Must be > 1.

  • max_delay_s (float) – Upper bound on the countdown (seconds). Prevents extremely long waits after many retries.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

max_retries: int
initial_delay_s: float
backoff_factor: float
max_delay_s: float
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].