Skip to content

developmentseed/zarrista

Repository files navigation

zarrista

PyPI

A low-level Zarr API for Python, inspired by zarrita.js, powered from Rust by Zarrs. Serving up Zarr chunks like your favorite barista!

This has been minimally vibe-coded: mostly but not fully written by hand. Some areas were prototyped with Claude.

This project is for evaluation, to consider whether natively binding to Zarrs can provide better performance. It is not yet production ready.

Documentation

Documentation website.

Features

  • Low-level, explicit Zarr access: open arrays and groups, read chunks, and inspect metadata without hidden machinery.
  • Both sync and async APIs (Array / AsyncArray, Group / AsyncGroup).
  • Rust core via Zarrs for compiled performance.
  • NumPy integration: read data into NumPy arrays through the buffer protocol for zero-copy sharing between Rust and Python.
  • Variety of data access
    • AWS S3, Google Cloud Storage, Azure Storage via Obstore
    • Icechunk integration
  • Full type hinting for all operations.

Example

Open a store, then open an Array from it:

from zarrista import Array, FilesystemStore

store = FilesystemStore("data/example.zarr")
array = Array.open(store, path="/temperature")

Inspect the array's metadata:

array.shape
# [720, 1440]

array.dtype
# DataType(float32)

array.dimension_names
# ["lat", "lon"]

Read a subset of the array. Indexing returns a Data buffer, which converts to a NumPy array:

data = array[0:128, 0:128]
arr = data.to_numpy()
arr.shape
# (128, 128)

You can also read individual chunks by their grid index:

data = array.retrieve_chunk([0, 0])

Development

Requires a Rust toolchain and Python 3.11+. We use uv and maturin.

# Create a dev environment and install the dev dependencies
uv sync --no-install-package zarrista

# Build the Rust extension and install it into the environment (debug build)
uv run --no-project maturin develop --uv

# Or, in release mode:
uv run --no-project maturin develop --uv --release

# Run the tests
uv run --no-project pytest

The --no-project is annoying but unavoidable in our current setup. Otherwise uv will try to build the rust library in release mode, as a dependency of the project before reaching uv sync or uv run.

About

A low-level Zarr API for Python, binding to Rust's Zarrs

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Contributors