Skip to main content

A simple, elegant, and efficient Zarr implementation.

Project description

simplezarr

A simple, elegant, and efficient Zarr implementation

Intro

Zarr 3 is a great file format for large datasets. It's nice and elegant. The simplezarr lib is what happens when one implemented this spec as directly as possible in Python.

Details

Parallelism and async are achieved using a thread-pool and concurrent.futures.Future objects. You can use it with async frameworks (like asyncio), but none of it is forced. You can use it synchronously and still benefit from parallelism. Calls that return a Future have a _soon suffix. Calls that are blocking have a _now suffix.

The core is simple, easy to follow, and gives predictable performance. Extra functionality is provided as functions and classes that are provided in simplezarr.utils. This keeps the lib light, and easy to adopt in a wide variety of use cases.

The Zarr 3.1 spec is fully implemented, except for sharding. The core has 100% test coverage.

Installation

pip install simplezarr

Quick example

Write a Zarr file to an in-memory store:

>>> import simplezarr

>>> store = simplezarr.MemoryStore()

>>> simplezarr.ZarrGroup.create(store, "")

>>> arr = simplezarr.ZarrArray.create(store, "array1", (1000, 1000), "uint16", chunk_shape=(64, 64))

>>> arr[...].set_now(42)

Reading:

>>> group = simplezarr.open_zarr(store)

>>> group
<ZarrGroup '' with 1 children at 0x10910a5d0>
    <ZarrArray 'array1' 1000x1000 uint16 at 0x10910a490>

>>> arr = group["array1"]

>>> a = arr[:100, :100].get_now()  # blocking, but reads chunks in parallel

>>> a
array([[42, 42, 42, ..., 42, 42, 42],
       [42, 42, 42, ..., 42, 42, 42],
       [42, 42, 42, ..., 42, 42, 42],
       ...,
       [42, 42, 42, ..., 42, 42, 42],
       [42, 42, 42, ..., 42, 42, 42],
       [42, 42, 42, ..., 42, 42, 42]], shape=(100, 100), dtype=uint16)

Parallel/lazy reads:

>>> f1 = array[:200, :200].get_soon()

>>> f2 = array[-200:, -200:].get_soon()

>>> a1, a2 = [f1.result(), f2.result()]

Developers

  • Clone the repo.
  • Install rendercanvas and developer deps using pip install -e .[dev].
  • Use ruff format to apply autoformatting.
  • Use ruff check to check for linting errors.
  • Use pytest tests to run the tests. Or pytest tests --cov=simplezarr --cov-report=html to get coverage reporting.

License

This code is distributed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simplezarr-1.0.0.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simplezarr-1.0.0-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

Details for the file simplezarr-1.0.0.tar.gz.

File metadata

  • Download URL: simplezarr-1.0.0.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for simplezarr-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dc4167db061ad7f5b25539afcb7cecd72daa4b6da0918b9afe19483eee03415c
MD5 e559f1a75c9a7b56325559b7778c38f1
BLAKE2b-256 691a526db30f9a2ed29308688e767740ce93dd510e7ba9bbfa44d7f1eb83307c

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplezarr-1.0.0.tar.gz:

Publisher: ci.yml on canpute/simplezarr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simplezarr-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: simplezarr-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 37.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for simplezarr-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce2a93c53fb78ffa87549b76e12fd64d223731a11115e75739b17e23b55dde0e
MD5 3cf78e3ff7f26aced5c6426eba63a299
BLAKE2b-256 93fca139743f19f97f56406087a6a9a2e4c4635d6ee9744a7fb2b40455d34e62

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplezarr-1.0.0-py3-none-any.whl:

Publisher: ci.yml on canpute/simplezarr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page