Pydantic models for the Zarr file format
Project Links
Meta
Author: Davis Bennett
Maintainer: David Stansby
Requires Python: >=3.12
Classifiers
Programming Language
- Python
- Python :: 3.12
- Python :: 3.13
- Python :: 3.14
- Python :: Implementation :: CPython
Typing
- Typed
pydantic-zarr
Installation
pip install -U pydantic-zarr
pydantic-zarr models Zarr metadata documents and does no IO; zarr-python moves the documents in and out of stores, as the usage guide shows.
Getting help
- Docs: see the documentation for detailed information about this project.
- Chat: We use Zulip for project-related chat.
Example
import json
import zarr
from zarr.core.buffer import default_buffer_prototype
from pydantic_zarr.v2 import GroupSpec
group = zarr.create_group(store={}, path='foo', zarr_format=2)
array = zarr.create_array(
store=group.store, name='foo/bar', shape=10, dtype='uint8', zarr_format=2
)
array.attrs.put({'metadata': 'hello'})
# collect the metadata documents zarr-python stored, keyed as the store keys them
prototype = default_buffer_prototype()
documents = {
f"{path}/{name}" if path else name: json.loads(buffer.to_bytes())
for path, node in [("", group), *group.members(max_depth=None)]
for name, buffer in node.metadata.to_buffer_dict(prototype).items()
}
# this is a pydantic model
spec = GroupSpec.from_stored_metadata_json(documents)
print(spec.model_dump())
"""
{
'zarr_format': 2,
'attributes': {},
'members': {
'bar': {
'zarr_format': 2,
'attributes': {'metadata': 'hello'},
'shape': (10,),
'chunks': (10,),
'dtype': '|u1',
'fill_value': 0,
'order': 'C',
'filters': None,
'dimension_separator': '.',
'compressor': {'id': 'zstd', 'level': 0},
}
},
}
"""
Development
Development tasks are driven by just — run
just --list for the available recipes — with environments installed from
uv.lock by uv. See the
contributing guide
for setup, testing, and changelog conventions.
History
This project was developed at HHMI / Janelia Research Campus. It was originally written by Davis Bennett to solve problems he encountered while working on the Cellmap Project team. In December of 2024 this project was migrated from the janelia-cellmap github organization to zarr-developers organization.
0.12.0
Nov 16, 2026
0.11.0
Nov 13, 2026
0.10.0
Apr 23, 2026
0.9.2
Mar 18, 2026
0.9.1
Dec 12, 2025
0.9.0
Dec 08, 2025
0.8.4
Sep 09, 2025
0.8.3
Sep 01, 2025
0.8.2
Aug 14, 2025
0.8.1
Aug 11, 2025
0.8.0
Jul 31, 2025
0.7.0
Mar 20, 2024
0.6.1
Mar 03, 2024
0.6.0
Mar 03, 2024
0.5.2
Nov 08, 2023
0.5.1
Oct 06, 2023
0.5.0
Aug 22, 2023
0.4.0
Jul 08, 2023
0.3.0
Jun 22, 2023
0.2.0
Jun 06, 2023
0.1.4
Jun 06, 2023
0.1.3
Jun 05, 2023
0.1.2
Jun 01, 2023
0.1.1
Jun 01, 2023
0.1.0
Jun 01, 2023
Wheel compatibility matrix
Files in release
Extras:
Dependencies:
numpy
(>=2.0.0)
packaging
(>=21.0)
pydantic
(>=2.12)
typing-extensions
(>=4.6)
zarr-metadata
(>=0.9.0)