virtualizarr.manifests.ChunkManifest#

class virtualizarr.manifests.ChunkManifest(entries: dict, shape: tuple[int, ...] | None = None)#

In-memory representation of a single Zarr chunk manifest.

Stores the manifest internally as numpy arrays, so the most efficient way to create this object is via the .from_arrays constructor classmethod.

The manifest can be converted to or from a dictionary which looks like this

{
“0.0.0”: {“path”: “s3://bucket/foo.nc”, “offset”: 100, “length”: 100},
“0.0.1”: {“path”: “s3://bucket/foo.nc”, “offset”: 200, “length”: 100},
“0.1.0”: {“path”: “s3://bucket/foo.nc”, “offset”: 300, “length”: 100},
“0.1.1”: {“path”: “s3://bucket/foo.nc”, “offset”: 400, “length”: 100},
}

using the .__init__() and .dict() methods, so users of this class can think of the manifest as if it were a dict mapping zarr chunk keys to byte ranges.

(See the chunk manifest SPEC proposal in zarr-developers/zarr-specs#287.)

Validation is done when this object is instantiated, and this class is immutable, so it’s not possible to have a ChunkManifest object that does not represent a valid grid of chunks.

__init__(entries: dict, shape: tuple[int, ...] | None = None) None#

Create a ChunkManifest from a dictionary mapping zarr chunk keys to byte ranges.

Parameters:

entries (dict) –

Chunk keys and byte range information, as a dictionary of the form

{
“0.0.0”: {“path”: “s3://bucket/foo.nc”, “offset”: 100, “length”: 100},
”0.0.1”: {“path”: “s3://bucket/foo.nc”, “offset”: 200, “length”: 100},
”0.1.0”: {“path”: “s3://bucket/foo.nc”, “offset”: 300, “length”: 100},
”0.1.1”: {“path”: “s3://bucket/foo.nc”, “offset”: 400, “length”: 100},
}

Methods

__init__(entries[, shape])

Create a ChunkManifest from a dictionary mapping zarr chunk keys to byte ranges.

dict()

Convert the entire manifest to a nested dictionary.

from_arrays(*, paths, offsets, lengths[, ...])

Create manifest directly from numpy arrays containing the path and byte range information.

from_zarr_json(filepath)

Create a ChunkManifest from a Zarr manifest.json file.

items()

keys()

rename_paths(new)

Rename paths to chunks in this manifest.

to_zarr_json(filepath)

Write the manifest to a Zarr manifest.json file.

values()

Attributes

nbytes

Size required to hold these references in memory in bytes.

ndim_chunk_grid

Number of dimensions in the chunk grid.

shape_chunk_grid

Number of separate chunks along each dimension.