base
base
¶
Abstract dataset schema for defining dataset-specific configurations.
This module provides a framework for supporting multiple datasets with different formats and observation modalities. Schemas define the structure of stored data (what's in the zarr file). They do not define how data is used at runtime (that's determined by task space config).
DatasetSchema
¶
Bases: ABC
Abstract base class for dataset schemas.
Defines common interface for zarr array creation, key management, and episode extraction. Subclasses (CsvDatasetSchema, Hdf5DatasetSchema) define format-specific data extraction.
Note
A schema defines the raw data structure for a specific dataset, including:
- What observations are available (position, gripper state, etc.).
- What action modalities exist (position, orientation, gripper).
- How to extract episode data via extract_episode.
The schema is used when creating the zarr file from the raw episodic data.
Initialize the dataset schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zarr_path
|
str
|
Path to save/load the zarr file |
required |
metadata
|
DatasetMetadata
|
Metadata of the raw dataset |
required |
dataset_type
|
str
|
Type of dataset (e.g., 'libero', 'tso', 'metaworld') |
required |
Source code in src/versatil/data/raw/schemas/base.py
extract_episode
abstractmethod
¶
Extract all data from an episode source.
Each schema defines its own extraction logic based on its metadata. The episode_source type depends on the schema format:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode_source
|
Any
|
Format-specific episode data source |
required |
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
Dictionary mapping zarr keys to numpy arrays |
Source code in src/versatil/data/raw/schemas/base.py
get_required_zarr_keys
¶
Get all required zarr keys based on the dataset metadata.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of all required zarr key names |
get_zarr_array_specs
¶
Get specifications for all zarr arrays to create for the store.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary mapping zarr key names to array specifications Each spec is a dict with: shape, chunks, dtype, needs_compressor |