dream.datasets
Import it as from dream import datasets.
Embodiments and datasets on the Dream Labs data service: describe a robot body, check a dataset locally, upload it.
dream.DreamClient carries the same calls with its key bound (add_embodiment(), get_embodiments(), validate_dataset(), upload_dataset(), get_dataset_status(), delete_dataset()); the functions here are the same calls on their own, for a caller that passes api_key itself. The functions:
- add_embodiment() and list_embodiments(): the robot bodies an account records datasets on. An embodiment is
<username>/<name>plus one config the user writes,{"state": {part: [start, end]}, "action": {part: [start, end]}, "video": {role: video_key}}: the named spans of the state and action vectors, and the camera roles mapped to the dataset’s video keys (add_embodiment() spells out every rule). The client checks the config before sending it, and the service refuses the same configs with the same line. - validate_dataset(): the checks a dataset must pass, run on a local directory against a config, answering a
Report. Nothing is sent and no key is needed. - upload_dataset(): fetches the embodiment’s config, runs the same checks, writes the dataset as one zip (the directory tree as it is, stored uncompressed: mp4 and parquet are compressed already), registers it, sends the zip straight to S3 on temporary credentials the service grants for that one object, and completes it; the service checks the zip is there at the declared size and answers the dataset
ready_to_process. Whatever fails after the registration is reported to the service, which marks the datasetfailed, and raised asDreamUploadError; the name is free again, so running the same call again starts over on the same dataset. A run the process did not survive (Ctrl+C, a crash) leaves the datasetuploading, and running it again reuses it too. Nothing is kept on the machine between runs. - get_dataset(): a dataset’s status as the service holds it now:
ready_to_processuntil processing starts,processingwhile it runs,processedonce it has (the one status a fine-tuning job is queued on), orfailedwhen the upload or the processing could not finish (errorsays why). list_datasets() answers every one of the account’s datasets, so an id upload_dataset() answered and was lost is found there by the dataset’s name.
A dataset directory holds one LeRobot v2.1 or v3.x dataset per subdirectory (<session>/meta/info.json, data/, videos/; each subdirectory name letters, digits, ., _ and -, at most 64), or is itself one (it has meta/info.json; its name is then the session’s). The service converts v3.x to v2.1 automatically before its existing processing and training stages. Hidden files (a .DS_Store, a .git/) are neither checked nor sent, nor is a note beside the session folders (a README, a .txt or a .md, validation.is_stray()): upload_dataset() warns Not uploaded: README.txt (not inside a session folder). for those.
Every call to the service takes your API key (api_key); left out, it is the credentials’ (DREAM_API_KEY). Where the service is comes from your credentials and is not a parameter. The local checks need pyarrow and the upload needs boto3. The library the platform offers carries both; an install without them raises DreamConfigError on the first call that needs them, saying how to install the library.
Errors: a refusal by the service is a DreamServerError whose code is the service’s (conflict for a name that is ready_to_process, processing or processed, not_found, invalid_request, validation; HTTP 5xx ones are retryable: make the same call again after a short wait). A key it does not accept is DreamAuthError, forbidden for an account with no username yet (ask Dream Labs support to set one). A service that cannot be reached, or an answer that is not the Dream API’s, is DreamProtocolError. A config that is not valid, a directory that is not one, or a missing key is DreamConfigError. A dataset the local checks refuse is DreamDatasetError; an upload that did not finish is DreamUploadError. Those two live in dream.errors, not the dream namespace.
Example
from dream import datasets config = { "state": {"arm": [0, 6], "gripper": [6, 7]}, "action": {"arm": [0, 6], "gripper": [6, 7]}, "video": {"overhead": "observation.images.top", "wrist": "observation.images.wrist"}, } datasets.add_embodiment("metal-arm", config, api_key=KEY) dataset = datasets.upload_dataset("~/data/towels", "towels-v1", "<your-username>/metal-arm", api_key=KEY) print(dataset.id, dataset.status, dataset.episodes, dataset.size_bytes)
Classes
Section titled “Classes”Embodiment: A robot body as the service records it; pass itsnameto upload_dataset().Report: What the local checks found:okand the counts, or the one line that refused the dataset.Dataset: One of your datasets on the service; keep itsidto follow its status.
dream.datasets.add_embodiment
Section titled “dream.datasets.add_embodiment”dream.datasets.add_embodiment( name: str, config: dict[str, Any], *, api_key: str | None = None, ) -> Embodiment
Records a robot body for your account; the config is checked here before it is sent.
The config is a dict:
state: each part of theobservation.statevector, by name, to its[start, end)span. The parts are your robot’s: their names, their widths and how many there are follow its arms. A body that records joints names them, e.g.{"right_arm": [0, 6], "right_gripper": [6, 7]}for one six-joint arm; one that records the end-effector pose names the EEF parts,{"right_eef_xyz": [0, 3], "right_eef_rot6": [3, 9], "right_grip": [9, 10]}, alone or beside the joints. The spans tile[0, width)with no gap or overlap, 128 wide at most.action: the same for theactionvector, which is what the model learns to answer: joint targets for the joint parts and end-effector targets for the EEF parts, as the dataset recorded them.video: each camera role to the dataset’s video key it reads, e.g.{"overhead": "observation.images.top"}; at least one.head_camera(optional when a role is namedoverhead): the role of the fixed head camera, the view the service labels the dataset’s tasks from; left out, theoverheadrole is used, and a body with neither is refused at registration.
Part names and roles are lowercase letters, digits and underscores, starting with a letter. No other key is taken; state_space and action_space, which older configs carried, are refused with a line saying so (shared.datasets.embodiments.check_registration). A body that records its end-effector pose names the six EEF parts (right_eef_xyz, right_eef_rot6, right_grip and the left three) among its parts like any other; whether a fine-tune trains them is dream.fine_tuning.create’s use_eef, not the config’s.
Parameters
name(str):[a-z0-9-]{1,64}, unique among your embodiments.config(dict[str, Any]): The embodiment config above.api_key(str | None, defaultNone, keyword-only): Your API key; the credentials’ when None.
Returns
Embodiment: The new Embodiment, named <username>/<name>: pass name to upload_dataset().
Raises
DreamConfigError: The config is not valid (the message says what is wrong), or there is no key.DreamAuthError: The key was refused, or the account has no username yet (forbidden).DreamServerError:conflictwhen you have an embodiment of that name;invalid_requestfor a bad name; aretryableone (HTTP 5xx) may be made again after a short wait. Every refusal’s message names the embodiment and the error code, and nothing of how the service is built.DreamProtocolError: The service could not be reached, or did not answer as the Dream API.
dream.datasets.list_embodiments
Section titled “dream.datasets.list_embodiments”dream.datasets.list_embodiments(*, api_key: str | None = None) -> list[Embodiment]
Your account’s embodiments.
Parameters
api_key(str | None, defaultNone, keyword-only): Your API key; the credentials’ when None.
Returns
list[Embodiment]: A list of Embodiment, newest first; an embodiment_config is what validate_dataset() takes, and an id is what a fine-tune’s Model names as its embodiment.
Raises
DreamConfigError: There is no key (and the credentials name none).DreamAuthError: The key was refused, or the account has no username yet (forbidden).DreamServerError: The service refused the call; aretryableone (HTTP 5xx, already retried by the client) may be made again after a short wait.DreamProtocolError: The service could not be reached, or did not answer as the Dream API.
dream.datasets.validate_dataset
Section titled “dream.datasets.validate_dataset”dream.datasets.validate_dataset( path: str | os.PathLike[str], config: dict[str, Any], ) -> Report
Runs the dataset checks on a local directory against an embodiment config; nothing is sent, no key needed.
These are the checks upload_dataset() runs before it sends anything, so a dataset that passes here passes there. They include each video’s format, read with FFmpeg: H.264, HEVC, AV1 or VP9 in MP4, without a subtitle track, as the service requires. A dataset that passes is also read for recording mistakes the checks cannot refuse (a joint that never moves, a jump between two frames, a frozen or black camera): the Report warnings, which are worth reading before a fine-tune is paid for.
Parameters
path(str | os.PathLike[str]): The dataset directory: one LeRobot v2.1 or v3.x dataset per subdirectory, or one such dataset itself;~is expanded, and hidden files are skipped. A v3.x dataset is checked as the v2.1 episodes the service converts it to automatically before training.config(dict[str, Any]): The embodiment config of the body it was recorded on (anEmbodiment’sembodiment_config).
Returns
Report: The Report: ok, the counts, the notes on what processing will change and the data-quality warnings, or ok=False and error, the one line to fix before uploading (a file that cannot be read is such a line too).
Raises
DreamConfigError: The directory does not exist or cannot be listed, pyarrow is not installed (the message says how to install the library), or the config is not valid.
dream.datasets.upload_dataset
Section titled “dream.datasets.upload_dataset”dream.datasets.upload_dataset( path: str | os.PathLike[str], name: str, embodiment: str, *, api_key: str | None = None, ) -> Dataset
Checks a local dataset against its embodiment, sends it to S3 as one zip and completes it.
The zip is written to the system’s temporary directory (tempfile.gettempdir(): TMPDIR when set) and removed before this returns or raises. It is stored uncompressed, so that directory needs free space about the dataset’s size; the call checks it before writing. A failure after the registration is reported to the service (the dataset is failed with the same line) before it is raised, and the name may be used again: running the same call again reuses the dataset. A name that is ready_to_process, processing or processed is taken for good. Each of the checks’ notes (Report notes: what processing will change) and data-quality warnings (Report warnings) is shown as a UserWarning before the upload; neither stops it.
Parameters
path(str | os.PathLike[str]): The dataset directory: one LeRobot v2.1 or v3.x dataset per subdirectory, or one such dataset itself. The service converts v3.x to v2.1 automatically before training; the upload is unchanged.name(str):[a-z0-9-]{1,64}; free unless one of your datasets of that name isready_to_process,processingorprocessed.embodiment(str): The body it was recorded on: one of your own, as<username>/<name>(anEmbodiment’sname); its config is fetched from the service.api_key(str | None, defaultNone, keyword-only): Your API key; the credentials’ when None.
Returns
Dataset: The Dataset as the service answered the completion, ready_to_process. Keep its id and poll get_dataset() until status is processed (then queue a fine-tuning job on its name) or failed (error says why).
Raises
DreamConfigError:nameis not[a-z0-9-]{1,64}(checked before anything is read or sent), the directory does not exist or cannot be listed, pyarrow or boto3 is not installed (the message says how to install the library), there is no key, or the temporary directory has less free space than the zip needs (the message gives both sizes and says to setTMPDIR; nothing was written or sent).DreamDatasetError: The local checks refused the dataset; nothing was sent.DreamUploadError: The zip could not be written, the transfer did not finish, or the service did not find the zip at the declared size; after the registration the dataset isfailed. Run the same call again.DreamAuthError: The key was refused, or the account has no username yet (forbidden).DreamServerError: The service refused the registration:conflictfor a name that isready_to_process,processingorprocessed,not_foundfor an embodiment that is not yours; aretryableone (HTTP 5xx) may be made again after a short wait.DreamProtocolError: The service could not be reached, or did not answer as the Dream API.
dream.datasets.get_dataset
Section titled “dream.datasets.get_dataset”dream.datasets.get_dataset(dataset_id: str, *, api_key: str | None = None) -> Dataset
One of your datasets by its id, with the status the service holds now.
Parameters
dataset_id(str): The dataset’s id (ds_+ hex), asupload_datasetanswered it.api_key(str | None, defaultNone, keyword-only): Your API key; the credentials’ when None.
Returns
Dataset: The Dataset: the same fields upload answered, status and error as they stand now (ready_to_process, processing, processed or failed). Poll until processed (a fine-tuning job can then be queued on it) or failed (error says why).
Raises
DreamConfigError: There is no key (and the credentials name none).DreamAuthError: The key was refused, or the account has no username yet (forbidden).DreamServerError:not_foundwhen no dataset of that id is yours; aretryableone (HTTP 5xx, already retried by the client) may be made again after a short wait.DreamProtocolError: The service could not be reached, or did not answer as the Dream API.
dream.datasets.list_datasets
Section titled “dream.datasets.list_datasets”dream.datasets.list_datasets(*, api_key: str | None = None) -> list[Dataset]
Your account’s datasets, newest first, each with the status the service holds now.
Parameters
api_key(str | None, defaultNone, keyword-only): Your API key; the credentials’ when None.
Returns
list[Dataset]: A list of Dataset, newest first: every dataset you registered, a failed or deleted one included, with its id (what get_dataset, retry_dataset and delete_dataset take) and its name (what a fine-tuning job names it by).
Raises
DreamConfigError: There is no key (and the credentials name none).DreamAuthError: The key was refused, or the account has no username yet (forbidden).DreamServerError: The service refused the call; aretryableone (HTTP 5xx, already retried by the client) may be made again after a short wait.DreamProtocolError: The service could not be reached, or did not answer as the Dream API.
dream.datasets.retry_dataset
Section titled “dream.datasets.retry_dataset”dream.datasets.retry_dataset(dataset_id: str, *, api_key: str | None = None) -> Dataset
Has a dataset whose processing failed processed again, from the zip already uploaded; nothing is sent again.
Parameters
dataset_id(str): The dataset’s id (ds_+ hex), asupload_datasetanswered it.api_key(str | None, defaultNone, keyword-only): Your API key; the credentials’ when None.
Returns
Dataset: The Dataset, ready_to_process; poll get_dataset as after an upload. A retry that raced another call on the same dataset (a second retry, an upload under its name) answers it as that call left it.
Raises
DreamConfigError: There is no key (and the credentials name none).DreamAuthError: The key was refused, or the account has no username yet (forbidden).DreamServerError:not_foundwhen no dataset of that id is yours, or the deployment offers no retries;conflictwhen it is notfailed, or its upload never finished (upload it again under the same name instead).DreamProtocolError: The service could not be reached, or did not answer as the Dream API.
dream.datasets.delete_dataset
Section titled “dream.datasets.delete_dataset”dream.datasets.delete_dataset( dataset_id: str, *, confirm: bool = True, api_key: str | None = None, ) -> Dataset | None
Deletes a dataset by its id after asking you to confirm.
A dataset with a fine-tuning job queued or running on it is refused until the job is over.
The answer is the dataset deleted, and get_dataset() answers it the same from then on.
Parameters
dataset_id(str): The dataset’s id (ds_+ hex), asupload_datasetanswered it.confirm(bool, defaultTrue, keyword-only): AskDelete dataset <id>? This cannot be undone. [y/N]on the terminal first; False skips it.api_key(str | None, defaultNone, keyword-only): Your API key; the credentials’ when None.
Returns
Dataset | None: The Dataset, deleted; None when you did not confirm, and nothing was sent.
Raises
DreamConfigError: There is no key (and the credentials name none).DreamAuthError: The key was refused, or the account has no username yet (forbidden).DreamServerError:not_foundwhen no dataset has that id;conflictwhile a fine-tuning job is queued or running on it where fine-tuning is priced.DreamProtocolError: The service could not be reached, or did not answer as the Dream API.