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:
- The call was wrong, and making it again gets the same error:
DreamConfigError(the config, the key, a URL, a path, a missing dependency),DreamObservationError(the observation),DreamActionError(the model’s reply did not match),DreamDatasetError(the dataset). Fix what the message names first. - No answer the client could read:
DreamTimeoutandDreamProtocolError. Check the URL and the network, then make the same call again. - A refusal:
DreamServerErrorand its subclassesDreamAuthError,DreamBadRequestandDreamSessionExpired, which carry the answer’scode,reason,retryableandretry_after_s. Whenretryableis True, waitretry_after_sseconds (a moment when it is None) and make the same call again; otherwise change the request.
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)
Classes
Section titled “Classes”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 withintimeout_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 isretryable.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-0001with a reason other thannew).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.