zarr_metadata.v3.codec
zarr_metadata.v3.codec ¶
Zarr v3 codec spec types.
Each codec defined by the spec or by zarr-extensions has its own submodule
(blosc, bytes, cast_value, crc32c, gzip, scale_offset,
sharding_indexed, transpose, zstd).
The <X>CodecMetadata aliases re-exported here are the canonical type for
each codec's permitted JSON shapes (object form plus, where the spec allows,
a bare-string short-hand form). For the underlying <X>CodecObject,
<X>CodecConfiguration, etc., import directly from the leaf submodule.
For the field-level "any codec entry" alias (used in array metadata's
codecs list and in sharding's inner pipelines), import ZarrV3MetadataFieldJSON
from zarr_metadata.v3.
See https://zarr-specs.readthedocs.io/en/latest/v3/codecs/index.html
zarr_metadata.v3.codec.blosc ¶
Blosc codec types.
See https://zarr-specs.readthedocs.io/en/latest/v3/codecs/blosc/index.html
BLOSC_CNAME
module-attribute
¶
BLOSC_CNAME: Final = (
"lz4",
"lz4hc",
"blosclz",
"snappy",
"zlib",
"zstd",
)
Tuple of permitted values for the cname field of the blosc codec.
BLOSC_CODEC_NAME
module-attribute
¶
BLOSC_CODEC_NAME: Final = 'blosc'
The name field value of the blosc codec.
BLOSC_SHUFFLE
module-attribute
¶
BLOSC_SHUFFLE: Final = (
"noshuffle",
"shuffle",
"bitshuffle",
)
Tuple of permitted values for the shuffle field of the blosc codec.
BloscCName
module-attribute
¶
BloscCName = Literal[
"lz4", "lz4hc", "blosclz", "snappy", "zlib", "zstd"
]
Literal type of blosc compressor identifiers.
BloscCodecMetadata
module-attribute
¶
BloscCodecMetadata = BloscCodecObject
Permitted JSON shape for blosc codec metadata.
The configuration has multiple required keys (cname, clevel, shuffle,
blocksize), so only the object form is valid; the short-hand-name form
is not permitted by the spec for this codec.
BloscCodecName
module-attribute
¶
BloscCodecName = Literal['blosc']
Literal type of the name field of the blosc codec.
BloscShuffle
module-attribute
¶
BloscShuffle = Literal["noshuffle", "shuffle", "bitshuffle"]
Literal type of blosc shuffle mode names.
__all__
module-attribute
¶
__all__ = [
"BLOSC_CNAME",
"BLOSC_CODEC_NAME",
"BLOSC_SHUFFLE",
"BloscCName",
"BloscCodecConfiguration",
"BloscCodecMetadata",
"BloscCodecName",
"BloscCodecObject",
"BloscShuffle",
]
BloscCodecConfiguration ¶
Bases: TypedDict
Configuration for the Zarr v3 blosc codec.
Source code in src/zarr_metadata/v3/codec/blosc.py
BloscCodecObject ¶
Bases: TypedDict
blosc codec metadata in object form.
Source code in src/zarr_metadata/v3/codec/blosc.py
zarr_metadata.v3.codec.bytes ¶
Bytes codec types.
See https://zarr-specs.readthedocs.io/en/latest/v3/codecs/bytes/index.html
BYTES_CODEC_NAME
module-attribute
¶
BYTES_CODEC_NAME: Final = 'bytes'
The name field value of the bytes codec.
BytesCodecMetadata
module-attribute
¶
BytesCodecMetadata = BytesCodecObject | BytesCodecName
Permitted JSON shapes for bytes codec metadata.
The configuration has no required keys (endian is conditionally required
at runtime based on data type), so the spec's short-hand-name form is
permitted in addition to the object form, and the object form may itself
omit configuration entirely.
BytesCodecName
module-attribute
¶
BytesCodecName = Literal['bytes']
Literal type of the name field of the bytes codec.
ENDIANNESS
module-attribute
¶
ENDIANNESS: Final = ('little', 'big')
Tuple of permitted values for the endian field of the bytes codec.
Endianness
module-attribute
¶
Endianness = Literal['little', 'big']
Literal type of byte order of multi-byte numeric data.
__all__
module-attribute
¶
__all__ = [
"BYTES_CODEC_NAME",
"ENDIANNESS",
"BytesCodecConfiguration",
"BytesCodecMetadata",
"BytesCodecName",
"BytesCodecObject",
"Endianness",
]
BytesCodecConfiguration ¶
Bases: TypedDict
Configuration for the Zarr v3 bytes codec.
The endian field is required for multi-byte data types.
Source code in src/zarr_metadata/v3/codec/bytes.py
BytesCodecObject ¶
Bases: TypedDict
bytes codec metadata in object form.
configuration is itself optional — when no configuration fields are
set, the entire configuration key may be omitted. This matches the
bare-string short-hand form (BytesCodecName) at the canonical data
level; both encodings describe a bytes codec with default settings.
Source code in src/zarr_metadata/v3/codec/bytes.py
zarr_metadata.v3.codec.cast_value ¶
Cast-value codec types.
See https://github.com/zarr-developers/zarr-extensions/tree/main/codecs/cast_value
CAST_OUT_OF_RANGE_MODE
module-attribute
¶
CAST_OUT_OF_RANGE_MODE: Final = ('clamp', 'wrap')
Tuple of permitted values for the out_of_range field of the cast_value codec.
CAST_ROUNDING_MODE
module-attribute
¶
CAST_ROUNDING_MODE: Final = (
"nearest-even",
"towards-zero",
"towards-positive",
"towards-negative",
"nearest-away",
)
Tuple of permitted values for the rounding field of the cast_value codec.
CAST_VALUE_CODEC_NAME
module-attribute
¶
CAST_VALUE_CODEC_NAME: Final = 'cast_value'
The name field value of the cast_value codec.
CastOutOfRangeMode
module-attribute
¶
CastOutOfRangeMode = Literal['clamp', 'wrap']
Literal type of permitted values for the out_of_range configuration field.
If absent, out-of-range values are an encoding/decoding error.
CastRoundingMode
module-attribute
¶
CastRoundingMode = Literal[
"nearest-even",
"towards-zero",
"towards-positive",
"towards-negative",
"nearest-away",
]
Literal type of permitted values for the rounding configuration field.
Defaults to "nearest-even" if absent.
CastValueCodecMetadata
module-attribute
¶
CastValueCodecMetadata = CastValueCodecObject
Permitted JSON shape for cast_value codec metadata.
configuration.data_type is required, so only the object form is valid;
the short-hand-name form is not permitted by the spec for this codec.
CastValueCodecName
module-attribute
¶
CastValueCodecName = Literal['cast_value']
Literal type of the name field of the cast_value codec.
ScalarMapEntry
module-attribute
¶
A single [input, output] mapping in a scalar_map direction.
Each scalar is JSON-encoded per its data type's fill-value rules (so
e.g. "NaN" and "+Infinity" are permitted).
__all__
module-attribute
¶
__all__ = [
"CAST_OUT_OF_RANGE_MODE",
"CAST_ROUNDING_MODE",
"CAST_VALUE_CODEC_NAME",
"CastOutOfRangeMode",
"CastRoundingMode",
"CastValueCodecConfiguration",
"CastValueCodecMetadata",
"CastValueCodecName",
"CastValueCodecObject",
"ScalarMap",
"ScalarMapEntry",
]
CastValueCodecConfiguration ¶
Bases: TypedDict
Configuration for the Zarr v3 cast_value codec.
data_type is the target data type that input values are cast to. It
is the same shape as the top-level array data_type field: either a
bare-string primitive name or a {name, configuration} envelope.
Source code in src/zarr_metadata/v3/codec/cast_value.py
CastValueCodecObject ¶
Bases: TypedDict
cast_value codec metadata in object form.
Source code in src/zarr_metadata/v3/codec/cast_value.py
ScalarMap ¶
Bases: TypedDict
Optional encode/decode scalar overrides for the cast_value codec.
Source code in src/zarr_metadata/v3/codec/cast_value.py
zarr_metadata.v3.codec.crc32c ¶
CRC32C codec types.
See https://zarr-specs.readthedocs.io/en/latest/v3/codecs/crc32c/index.html
The CRC32C codec has no configuration fields, so the configuration
key is absent from the metadata.
CRC32C_CODEC_NAME
module-attribute
¶
CRC32C_CODEC_NAME: Final = 'crc32c'
The name field value of the crc32c codec.
Crc32cCodecMetadata
module-attribute
¶
Crc32cCodecMetadata = Crc32cCodecObject | Crc32cCodecName
Permitted JSON shapes for crc32c codec metadata.
The spec's Extension definition allows extensions with no required configuration to be encoded as a bare short-hand name. CRC32C has no configuration, so both forms are valid.
Crc32cCodecName
module-attribute
¶
Crc32cCodecName = Literal['crc32c']
Literal type of the name field of the crc32c codec.
__all__
module-attribute
¶
Crc32cCodecObject ¶
Bases: TypedDict
crc32c codec metadata in object form.
Per spec the codec has no configuration fields. configuration is
optional and, if present, should be an empty mapping.
Source code in src/zarr_metadata/v3/codec/crc32c.py
zarr_metadata.v3.codec.gzip ¶
Gzip codec types.
See https://zarr-specs.readthedocs.io/en/latest/v3/codecs/gzip/index.html
GZIP_CODEC_NAME
module-attribute
¶
GZIP_CODEC_NAME: Final = 'gzip'
The name field value of the gzip codec.
GzipCodecMetadata
module-attribute
¶
GzipCodecMetadata = GzipCodecObject
Permitted JSON shape for gzip codec metadata.
configuration.level is required (it determines the codec's output bytes
and is therefore part of the metadata's reproducibility contract), so
only the object form is valid; the short-hand-name form is not permitted.
GzipCodecName
module-attribute
¶
GzipCodecName = Literal['gzip']
Literal type of the name field of the gzip codec.
__all__
module-attribute
¶
__all__ = [
"GZIP_CODEC_NAME",
"GzipCodecConfiguration",
"GzipCodecMetadata",
"GzipCodecName",
"GzipCodecObject",
]
GzipCodecConfiguration ¶
Bases: TypedDict
Configuration for the Zarr v3 gzip codec.
level is an integer in the range 0-9; 0 disables compression and 9
is slowest with the best compression ratio. The codec's compressed
output depends on level, so metadata that omits it cannot
reproducibly identify the chunk bytes produced by a writer — level
is required for the metadata to fulfill its reproducibility role,
even though the spec text does not mark it required with RFC 2119
keywords.
Source code in src/zarr_metadata/v3/codec/gzip.py
GzipCodecObject ¶
Bases: TypedDict
gzip codec metadata in object form.
Source code in src/zarr_metadata/v3/codec/gzip.py
zarr_metadata.v3.codec.scale_offset ¶
Scale-offset codec types.
See https://github.com/zarr-developers/zarr-extensions/tree/main/codecs/scale_offset
SCALE_OFFSET_CODEC_NAME
module-attribute
¶
SCALE_OFFSET_CODEC_NAME: Final = 'scale_offset'
The name field value of the scale_offset codec.
ScaleOffsetCodecMetadata
module-attribute
¶
ScaleOffsetCodecMetadata = (
ScaleOffsetCodecObject | ScaleOffsetCodecName
)
Permitted JSON shapes for scale_offset codec metadata.
The configuration has no required keys (both offset and scale are
optional, and the configuration itself is optional), so the short-hand-name
form is permitted in addition to the object form.
ScaleOffsetCodecName
module-attribute
¶
ScaleOffsetCodecName = Literal['scale_offset']
Literal type of the name field of the scale_offset codec.
__all__
module-attribute
¶
__all__ = [
"SCALE_OFFSET_CODEC_NAME",
"ScaleOffsetCodecConfiguration",
"ScaleOffsetCodecMetadata",
"ScaleOffsetCodecName",
"ScaleOffsetCodecObject",
]
ScaleOffsetCodecConfiguration ¶
Bases: TypedDict
Configuration for the Zarr v3 scale_offset codec.
Both fields are optional. A missing offset is the additive identity
(e.g. 0 for numeric types); a missing scale is the multiplicative
identity (e.g. 1). Each scalar is JSON-encoded per the input array's
fill-value rules, so "NaN" and "+Infinity" style strings are
permitted in addition to numbers.
Source code in src/zarr_metadata/v3/codec/scale_offset.py
ScaleOffsetCodecObject ¶
Bases: TypedDict
scale_offset codec metadata in object form.
configuration is itself optional per spec — when both offset and
scale are at their identity defaults, the codec is a no-op and the
entire configuration field may be omitted.
Source code in src/zarr_metadata/v3/codec/scale_offset.py
zarr_metadata.v3.codec.sharding_indexed ¶
Sharding-indexed codec types.
See https://zarr-specs.readthedocs.io/en/latest/v3/codecs/sharding-indexed/index.html
SHARDING_INDEXED_CODEC_NAME
module-attribute
¶
SHARDING_INDEXED_CODEC_NAME: Final = 'sharding_indexed'
The name field value of the sharding_indexed codec.
SHARDING_INDEX_LOCATION
module-attribute
¶
SHARDING_INDEX_LOCATION: Final = ('start', 'end')
Tuple of permitted values for the index_location field of the sharding_indexed codec.
ShardingIndexLocation
module-attribute
¶
ShardingIndexLocation = Literal['start', 'end']
Literal type of the position of the shard index within the encoded shard.
ShardingIndexedCodecMetadata
module-attribute
¶
ShardingIndexedCodecMetadata = ShardingIndexedCodecObject
Permitted JSON shape for sharding_indexed codec metadata.
The configuration has multiple required keys (chunk_shape, codecs,
index_codecs), so only the object form is valid; the short-hand-name
form is not permitted by the spec for this codec.
ShardingIndexedCodecName
module-attribute
¶
ShardingIndexedCodecName = Literal['sharding_indexed']
Literal type of the name field of the sharding_indexed codec.
__all__
module-attribute
¶
__all__ = [
"SHARDING_INDEXED_CODEC_NAME",
"SHARDING_INDEX_LOCATION",
"ShardingIndexLocation",
"ShardingIndexedCodecConfiguration",
"ShardingIndexedCodecMetadata",
"ShardingIndexedCodecName",
"ShardingIndexedCodecObject",
]
ShardingIndexedCodecConfiguration ¶
Bases: TypedDict
Configuration for the Zarr v3 sharding_indexed codec.
chunk_shape is the shape of inner chunks along each dimension;
it must evenly divide the shard shape.
codecs is the codec pipeline applied to each inner chunk; exactly
one array-to-bytes codec is required.
index_codecs is the codec pipeline applied to the shard index;
it must be deterministic (no variable-size compression).
index_location defaults to "end" per the spec.
Source code in src/zarr_metadata/v3/codec/sharding_indexed.py
ShardingIndexedCodecObject ¶
Bases: TypedDict
sharding_indexed codec metadata in object form.
Source code in src/zarr_metadata/v3/codec/sharding_indexed.py
zarr_metadata.v3.codec.transpose ¶
Transpose codec types.
See https://zarr-specs.readthedocs.io/en/latest/v3/codecs/transpose/index.html
TRANSPOSE_CODEC_NAME
module-attribute
¶
TRANSPOSE_CODEC_NAME: Final = 'transpose'
The name field value of the transpose codec.
TransposeCodecMetadata
module-attribute
¶
TransposeCodecMetadata = TransposeCodecObject
Permitted JSON shape for transpose codec metadata.
order is required, so only the object form is valid; the short-hand-name
form is not permitted by the spec for this codec.
TransposeCodecName
module-attribute
¶
TransposeCodecName = Literal['transpose']
Literal type of the name field of the transpose codec.
__all__
module-attribute
¶
__all__ = [
"TRANSPOSE_CODEC_NAME",
"TransposeCodecConfiguration",
"TransposeCodecMetadata",
"TransposeCodecName",
"TransposeCodecObject",
]
TransposeCodecConfiguration ¶
Bases: TypedDict
Configuration for the Zarr v3 transpose codec.
order is a permutation of the dimension indices 0..n-1 that
specifies the dimension reordering applied during encoding.
Source code in src/zarr_metadata/v3/codec/transpose.py
TransposeCodecObject ¶
Bases: TypedDict
transpose codec metadata in object form.
Source code in src/zarr_metadata/v3/codec/transpose.py
zarr_metadata.v3.codec.zstd ¶
Zstandard codec types.
See https://github.com/zarr-developers/zarr-specs/pull/256 (unmerged at time of writing; the configuration shape below reflects the proposed specification).
ZSTD_CODEC_NAME
module-attribute
¶
ZSTD_CODEC_NAME: Final = 'zstd'
The name field value of the zstd codec.
ZstdCodecMetadata
module-attribute
¶
ZstdCodecMetadata = ZstdCodecObject
Permitted JSON shape for zstd codec metadata.
Both level and checksum are required, so only the object form is
valid; the short-hand-name form is not permitted by the spec for this codec.
ZstdCodecName
module-attribute
¶
ZstdCodecName = Literal['zstd']
Literal type of the name field of the zstd codec.
__all__
module-attribute
¶
__all__ = [
"ZSTD_CODEC_NAME",
"ZstdCodecConfiguration",
"ZstdCodecMetadata",
"ZstdCodecName",
"ZstdCodecObject",
]
ZstdCodecConfiguration ¶
Bases: TypedDict
Configuration for the Zarr v3 zstd codec.
Both fields are required per the proposed specification.
Source code in src/zarr_metadata/v3/codec/zstd.py
ZstdCodecObject ¶
Bases: TypedDict
zstd codec metadata in object form.