zarrs
zarrs is a Rust library for the Zarr storage format for multidimensional arrays and metadata.
[!TIP] If you are a Python user, check out
zarrs-python. It includes a high-performance codec pipeline for the referencezarr-pythonimplementation.
zarrs supports Zarr V3 and a V3 compatible subset of Zarr V2.
It is fully up-to-date and conformant with the Zarr 3.1 specification with support for:
- all core extensions (data types, codecs, chunk grids, chunk key encodings, storage transformers),
- all accepted Zarr Enhancement Proposals (ZEPs) and several draft ZEPs:
- ZEP 0003: Variable chunking
- ZEP 0007: Strings
- ZEP 0009: Zarr Extension Naming
- various registered extensions from zarr-developers/zarr-extensions/,
- experimental codecs and data types intended for future registration, and
- user-defined custom extensions and stores.
A changelog can be found here. Correctness issues with past versions are detailed here.
Developed at the Department of Materials Physics, Australian National University, Canberra, Australia.
Getting Started
- Review the implementation status which summarises zarr version support, array support (codecs, data types, etc.) and storage support.
- Read The
zarrsBook. - View the examples and the example below.
- Read the documentation.
- Check out the
zarrsecosystem.
Example
use GroupBuilder;
use ;
use GzipCodec; // requires gzip feature
use ArraySubset;
use ReadableWritableListableStorage;
use FilesystemStore; // requires filesystem feature
// Create a filesystem store
let store_path: PathBuf = "/path/to/hierarchy.zarr".into;
let store: ReadableWritableListableStorage =
new;
// Write the root group metadata
new
.build?
// .attributes(...)
.store_metadata?;
// Create a new V3 array using the array builder
let array = new
.bytes_to_bytes_codecs
.dimension_names
.attributes
.build?; // /path/to/hierarchy.zarr/array
// Store the array metadata
array.store_metadata?;
println!;
// {
// "zarr_format": 3,
// "node_type": "array",
// ...
// }
// Perform some operations on the chunks
array.?;
array.?;
array.erase_chunk?;
// Retrieve all array elements as an ndarray
let array_ndarray = array.?;
println!;
// [[ NaN, NaN, 0.2, 0.3],
// [ NaN, -1.1, -1.2, 1.3],
// [ NaN, -2.1, NaN, NaN]]
zarrs Ecosystem
The Zarr specification is inherently unstable. It is under active development and new extensions are continually being introduced.
The zarrs crate has been split into multiple crates to:
- allow external implementations of stores and extensions points to target a relatively stable API compatible with a range of
zarrsversions, - enable automatic backporting of metadata compatibility fixes and changes due to standardisation,
- stay up-to-date with unstable public dependencies (e.g.
opendal,object_store,icechunk, etc) without impacting the release cycle ofzarrs, and - improve compilation times.
A hierarchical overview of these crates can be found in the The zarrs Book.
Core
zarrs: The core library for manipulating Zarr hierarchies.zarrs_metadata: Zarr metadata support (re-exported aszarrs::metadata).zarrs_metadata_ext: Zarr extensions metadata support (re-exported aszarrs::metadata_ext).zarrs_data_type: The data type extension API forzarrs(re-exported inzarrs::array::data_type).zarrs_storage: The storage API forzarrs(re-exported aszarrs::storage).zarrs_plugin: The plugin API forzarrs(re-exported aszarrs::plugin).zarrs_registry: The Zarr extension point registry forzarrs(re-exported aszarrs::registry).
Stores
zarrs_filesystem: A filesystem store (re-exported aszarrs::filesystem).zarrs_object_store:object_storestore support.zarrs_opendal:opendalstore support.zarrs_http: A synchronous http store.zarrs_zip: A storage adapter for zip files.zarrs_icechunk:icechunkstore support.git-like version control for Zarr hierachies.- Read "virtual Zarr datacubes" of archival formats (e.g.,
netCDF4,HDF5, etc.) created byVirtualiZarrand backed byicechunk.
Bindings
zarrs-python: A high-performance codec pipeline forzarr-python.zarrs_ffi: A subset ofzarrsexposed as a C/C++ API.
Zarr Metadata Conventions
ome_zarr_metadata: A library for OME-Zarr (previously OME-NGFF) metadata.
Tools
zarrs_tools: Various tools for creating and manipulating Zarr V3 data with thezarrsrust crate- A reencoder that can change codecs, chunk shape, convert Zarr V2 to V3, etc.
- Create an OME-Zarr hierarchy from a Zarr array.
- Transform arrays: crop, rescale, downsample, gradient magnitude, gaussian, noise filtering, etc.
Benchmarks
zarr_benchmarks: Benchmarks of various Zarr V3 implementations:zarrs,zarr-python,tensorstore
Licence
zarrs is licensed under either of
- the Apache License, Version 2.0 LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0 or
- the MIT license LICENSE-MIT or http://opensource.org/licenses/MIT, at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.