Skip to content

DreamServerError

class DreamServerError(DreamError, RuntimeError)

Importable as dream.DreamServerError.

A refusal, carried with the answer’s code and reason; whether to call again is retryable.

The codes come in two families:

  • From get_action(), the model’s status codes: DA-2000 (the call cannot be taken right now: reason pool_warming means the model is starting, rate_limited that the calls came too fast, pool_full and queue_timeout that it is at max capacity, max_serves that it is at max capacity and no more copies of it may start: not retryable, but with retry_after_s set a call after that wait may find a seat freed), DA-5000 (the model failed the call) and DA-6000 (a fault on the Dream Labs side; cannot_scale means the model cannot be started, and the message says why).
  • From the embodiment, dataset, fine-tuning and model calls, the service’s own lowercase codes, with reason None: not_found (no such embodiment, dataset or job on this account), conflict (a name in use, a dataset not processed, a job already finished, the account at its limit of active jobs), invalid_request (a name, suffix or fine-tuning knob out of range; the message names it), validation (a value of the wrong type), and the HTTP 5xx ones, which are retryable.

When retryable is True, wait retry_after_s seconds (a moment when it is None) and make the same call again; otherwise the same call gets the same answer, so change it first.

Attributes

  • code (str | None): The code, e.g. "DA-2000" from get_action() or "not_found" from the other calls; None when the answer carried none.
  • reason (str | None): Why, e.g. "pool_warming"; None when the answer carried none (always None outside get_action()).
  • retryable (bool): Whether the same call may be made again: as the model’s answer says for get_action(), and True for an HTTP 5xx answer of the other calls.
  • retry_after_s (float | None): Seconds to wait before calling again, or None.
  • message (str): The message; also what str(error) returns.

Raised by

Subclasses: DreamBadRequest, DreamAuthError, DreamSessionExpired

DreamServerError(
    message: str,
    code: str | None = None,
    reason: str | None = None,
    retryable: bool = False,
    retry_after_s: float | None = None,
)

Stores the answer’s fields as they came; the client raises it, a caller never needs to construct one.

Parameters

  • message (str): Human-readable text, shown verbatim to the caller.
  • code (str | None, default None): The answer’s code.
  • reason (str | None, default None): The answer’s reason.
  • retryable (bool, default False): Whether the same call may be made again.
  • retry_after_s (float | None, default None): Seconds to wait before calling again.