https://github.com/zarr-developers/pydantic-zarr
Pydantic models for Zarr
https://github.com/zarr-developers/pydantic-zarr
Last synced: 7 months ago
JSON representation
Pydantic models for Zarr
- Host: GitHub
- URL: https://github.com/zarr-developers/pydantic-zarr
- Owner: zarr-developers
- License: bsd-3-clause
- Created: 2023-05-30T20:55:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-06-08T08:18:44.000Z (8 months ago)
- Last Synced: 2025-06-26T14:11:34.161Z (7 months ago)
- Language: Python
- Size: 758 KB
- Stars: 32
- Watchers: 4
- Forks: 3
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pydantic-zarr
[](https://pypi.python.org/pypi/pydantic-zarr)
[Pydantic](https://docs.pydantic.dev/latest/) models for [Zarr](https://zarr.readthedocs.io/en/stable/index.html).
## Installation
`pip install -U pydantic-zarr`
## Getting help
- Docs: see the [documentation](https://zarr.dev/pydantic-zarr/) for detailed information about this project.
- Chat: We use [Zulip](https://ossci.zulipchat.com/#narrow/channel/423692-Zarr) for project-related chat.
## Example
```python
import zarr
from pydantic_zarr import GroupSpec
group = zarr.group(path='foo')
array = zarr.create(store = group.store, path='foo/bar', shape=10, dtype='uint8')
array.attrs.put({'metadata': 'hello'})
# this is a pydantic model
spec = GroupSpec.from_zarr(group)
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': 'blosc',
'cname': 'lz4',
'clevel': 5,
'shuffle': 1,
'blocksize': 0,
},
}
},
}
"""
```
## History
This project was developed at [HHMI / Janelia Research Campus](https://www.janelia.org/). It was originally written by Davis Bennett to solve problems he encountered while working on the [Cellmap Project team](https://www.janelia.org/project-team/cellmap/members). In December of 2024 this project was migrated from the [`janelia-cellmap`](https://github.com/janelia-cellmap) github organization to [`zarr-developers`](https://github.com/zarr-developers) organization.