Skip to content

dream.errors

Import it as from dream import errors.

The errors the dream client raises.

Every error the client raises derives from DreamError, so except dream.DreamError catches all of them, and each also derives from a builtin (ValueError, TimeoutError or RuntimeError), so code that catches the builtin keeps working. They fall in three families:

DreamUploadError is an upload that did not finish; running the upload again retries it. It and DreamDatasetError, the two errors only the dataset upload raises, are not in the dream namespace: from dream.errors import DreamDatasetError, DreamUploadError.

One more type here is a warning, not an error: DreamSlowNetworkWarning, issued (never raised) when the inference client’s recent round trips stay slow. Its page says how to silence it.

Example

import time

import dream

def act(client, observation):
    while True:
        try:
            return client.get_action(observation)
        except dream.DreamServerError as error:
            if not error.retryable:
                raise
            time.sleep(error.retry_after_s or 1.0)
  • DreamError: Base of every error the client raises; also raised as itself when a client is used wrongly.
  • DreamConfigError: Something the caller passed or configured is wrong; the message says what, and the same call fails again.
  • DreamObservationError: An observation that cannot be sent; raised before anything is sent, with the key named in the message.
  • DreamActionError: The model’s reply is not an action the client can return; nothing is returned, and the message names the key.
  • DreamTimeout: The model did not answer within timeout_ms (15000 ms unless the config sets it).
  • DreamProtocolError: No answer the client could read: the host could not be reached, or what answered is not the Dream API.
  • DreamServerError: A refusal, carried with the answer’s code and reason; whether to call again is retryable.
  • DreamAuthError: The API key was refused; never retryable: check the key, or the account, before calling again.
  • DreamBadRequest: The model refused the request as malformed (DA-4000); never retryable, the request must change.
  • DreamSessionExpired: The model replaced the session in the middle of an episode (DA-0001 with a reason other than new).
  • DreamDatasetError: The local checks refused the dataset, and nothing was sent; str(error) is the one line to fix.
  • DreamUploadError: An upload that did not finish; str(error) is the one line, and running the upload again retries it.
  • DreamSlowNetworkWarning: A Python warning, not an error: the inference client’s recent round trips are slow, and the robot’s motion may be less smooth.