create_zarr_arrays
create_zarr_arrays
¶
Shared zarr replay buffer creation utilities.
Provides a unified pipeline for creating zarr stores from any dataset schema, with WebP compression for uint8 images and lz4 for numerical arrays.
create_zarr_arrays
¶
create_zarr_arrays(data_group, schema, image_codec, numeric_compressor, image_frames_per_shard=DEFAULT_IMAGE_FRAMES_PER_SHARD)
Create zarr arrays with codec selection based on data type.
Uses WebP compression for uint8 image arrays and Blosc/lz4 for numerical arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_group
|
Group
|
Zarr group to create arrays in. |
required |
schema
|
DatasetSchema
|
Dataset schema providing array specifications. |
required |
image_codec
|
WebPCodec
|
WebP codec for uint8 image arrays. |
required |
numeric_compressor
|
BloscCodec
|
Blosc codec for numerical arrays. |
required |
image_frames_per_shard
|
int | None
|
Number of independently compressed image frames stored in each shard, or None to disable sharding. |
DEFAULT_IMAGE_FRAMES_PER_SHARD
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If image_frames_per_shard is not an integer. |
ValueError
|
If image_frames_per_shard is not a positive multiple of the image chunk length. |
Source code in src/versatil/data/preprocessing/create_zarr_arrays.py
create_zarr_replay_buffer
¶
create_zarr_replay_buffer(schema, episodes, total_episodes=None, image_frames_per_shard=DEFAULT_IMAGE_FRAMES_PER_SHARD)
Create a zarr replay buffer from an iterable of episodes.
Handles store creation, array setup with proper codecs, episode insertion, and metadata. Uses WebP for uint8 images and lz4 for numerical data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
DatasetSchema
|
Dataset schema with zarr_path and array specs. |
required |
episodes
|
Iterable[dict[str, ndarray]]
|
Iterable yielding episode dicts mapping keys to arrays. |
required |
total_episodes
|
int | None
|
Total number of episodes for progress reporting. |
None
|
image_frames_per_shard
|
int | None
|
Number of independently compressed image frames stored in each shard, or None to disable sharding. |
DEFAULT_IMAGE_FRAMES_PER_SHARD
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If image_frames_per_shard is not an integer. |
ValueError
|
If image_frames_per_shard is not a positive multiple of the image chunk length. |