zarr_metadata.v3.definition
zarr_metadata.v3.definition ¶
The kinds of metadata in a Zarr v3 document, and the scopes this package provides for it.
The kind of metadata a definition defines is its type: CodecDefinition
(with the codec's kind, and its size: "static" if the output size
is determined by the input size, or "dynamic" if it depends on the
values), DataTypeDefinition, ChunkGridDefinition,
ChunkKeyEncodingDefinition, StorageTransformerDefinition, and, for
the members of a document that the spec does not define,
ArrayExtraFieldDefinition and GroupExtraFieldDefinition. What a
definition is and how a field is read are in zarr_metadata.definition,
which both formats share. ZarrV3Context is the v3 scope, with one slot
for each kind: data_types, chunk_grids, chunk_key_encodings,
codecs, storage_transformers, array_extra_fields and
group_extra_fields. CORE and CORE_AND_EXTENSIONS are the v3 scopes
this package provides.
A scope reads whole documents as well as fields.
read_array_metadata_v3(document, context=CONTEXT), from
zarr_metadata.model, reads each extension point of a v3 array document
through the definitions in CONTEXT, and so do the model's from_json and
from_key_value. The fill value is checked against the data type it
names, by that data type's definition. The chunk grid is checked against
the shape, by the grid's definition. The codecs are checked as a
pipeline, each by its definition against the chunk it receives.
A member that holds another metadata field is annotated with the field
alias of its kind (a shard's codecs: tuple[ZarrV3CodecField, ...]) and
is read in the same scope as its parent field. A problem with the nested
field belongs to that field and is reported at its location. The parent
field is still read, as a document containing the nested field would be.
A member that accepts only codecs of static size is annotated
ZarrV3StaticCodecField. A shard's index_codecs uses this, because a
reader locates the index from a size it knows before reading it. A codec
of dynamic size in such a member is a problem at its location, when the
field is read in a scope. A name that nothing claims is not checked, and
its size is unknown, like everything else about it.
ZarrV3MetadataFieldJSON describes the same JSON, but it is checked
only as JSON, so a definition rejects a member typed with it. An
extension with nothing to configure uses EmptyConfiguration, and is
written with its name only.
A data type also declares how its values are stored. storage is a
function of the configuration and the nested fields that returns a
StorageClass: single bytes, several bytes at a time, or each value in
as many bytes as it needs. A struct's storage depends on its fields.
storage_of(data_type) calls it for a data type field the scope read.
The bytes codec requires an endian for multi-byte numbers, and a
struct rejects a field whose values vary in size. A data type that does
not declare storage leaves it unknown.
A chunk grid declares which array shapes it fits with shape_rules, a
function that yields the spec violations in a grid with its
configuration over an array of a given shape (a dimension with no chunk
length, or chunks that do not cover the dimension), located in the
configuration. A grid that does not declare shape rules fits every
shape. It also declares the lengths of its chunks along each axis of an
array it fits, with chunk_lengths: a set per axis, because a
rectilinear grid's chunks differ in length. A reading stores both
results for the grid it read: an entry for each dimension of the shape,
with None where the lengths are unknown.
A codec is checked against its input. The array passes its first codec
a Chunk: the lengths of the grid's chunks along each of the array's
dimensions, and the array's data type field, with None for unknown
parts. A codec that receives an array declares the spec violations for
a given chunk with chunk_rules, located in its configuration (for
example, a transpose whose order has the wrong number of axes). An
array -> array codec declares what it passes to the next codec with
transition, whatever its chunk rules found. For example, transpose
permutes the axes. A reading reads the codec fields as a pipeline. It
checks their order (array -> array codecs, one array -> bytes codec,
bytes -> bytes codecs), then checks each codec against the chunk it
receives, and records a Stage for each codec with that chunk. A codec
that contains its own pipelines declares what each one receives with
pipelines, keyed by the configuration member that holds each
pipeline. For example, a shard's inner codecs receive its inner chunks,
and its index codecs receive the shard index. Each pipeline is read the
same way, and its stages are stored as the codec's Stage.inner.
The reader does not guess. After a codec the scope did not read, or
after a codec that does not declare its output, the next codec receives
a chunk with nothing known about it, Chunk(), which never causes a
problem. A later codec can still declare its own output.
Raw bits are the only data type whose name encodes its configuration. A
document writes r followed by the size in bits, and r16 is read as
r* (the notation in the specification's table of data types) with
{"bits": 16}. A reader that wants to read raw bits its own way defines
r*. A data type named r16 is rejected, because that name is read as
r*. r* itself is notation, and a document that uses it as a name
refers to nothing in any scope.
JSON Schema. zarr_metadata.json_schema writes a v3 field, or a whole
zarr.json, as a JSON Schema.
CORE
module-attribute
¶
CORE: Final = ZarrV3Context(
data_types=(
BOOL_DATA_TYPE,
INT8_DATA_TYPE,
INT16_DATA_TYPE,
INT32_DATA_TYPE,
INT64_DATA_TYPE,
UINT8_DATA_TYPE,
UINT16_DATA_TYPE,
UINT32_DATA_TYPE,
UINT64_DATA_TYPE,
FLOAT16_DATA_TYPE,
FLOAT32_DATA_TYPE,
FLOAT64_DATA_TYPE,
COMPLEX64_DATA_TYPE,
COMPLEX128_DATA_TYPE,
RAW_BYTES_DATA_TYPE,
),
chunk_grids=(REGULAR_CHUNK_GRID,),
chunk_key_encodings=(
DEFAULT_CHUNK_KEY_ENCODING,
V2_CHUNK_KEY_ENCODING,
),
codecs=(
BLOSC_CODEC,
BYTES_CODEC,
CRC32C_CODEC,
GZIP_CODEC,
SHARDING_INDEXED_CODEC,
TRANSPOSE_CODEC,
),
group_extra_fields=(CONSOLIDATED_METADATA_EXTRA_FIELD,),
)
A scope with only what the Zarr v3 specification defines, including the envelope of a group's consolidated_metadata, which the spec fixes.
CORE_AND_EXTENSIONS
module-attribute
¶
CORE_AND_EXTENSIONS: Final = CORE.update(
data_types=[
*CORE.data_types.values(),
BYTES_DATA_TYPE,
STRING_DATA_TYPE,
NUMPY_DATETIME64_DATA_TYPE,
NUMPY_TIMEDELTA64_DATA_TYPE,
STRUCT_DATA_TYPE,
],
chunk_grids=[
*CORE.chunk_grids.values(),
RECTILINEAR_CHUNK_GRID,
],
codecs=[
*CORE.codecs.values(),
CAST_VALUE_CODEC,
SCALE_OFFSET_CODEC,
ZSTD_CODEC,
],
)
A scope with what the specification defines, plus the extensions that zarr-extensions registers and this package defines.
CodecKind
module-attribute
¶
CodecKind = Literal[
"array_array", "array_bytes", "bytes_bytes"
]
What a codec converts its input to: the three positions a pipeline puts in order.
CodecSize
module-attribute
¶
CodecSize = Literal['static', 'dynamic']
Whether the size of a codec's output is determined by the size of its input.
static: it is. For example, bytes writes each element at its width,
and crc32c adds four bytes. dynamic: the size depends on the values,
as for every compressor.
Lengths
module-attribute
¶
For each axis, every chunk length along that axis (a set, because a rectilinear grid's lengths differ), or None where unknown.
StorageClass
module-attribute
¶
StorageClass = Literal[
"single_byte", "multi_byte", "variable_length"
]
How a data type's values are stored: in single bytes, in several bytes at a time, or each value in as many bytes as it needs.
A multi-byte number is stored in a byte order, which the bytes codec's
endian sets. A value made of single bytes (a uint8, or a struct of
int8 fields) has no byte order. A value whose size varies needs its
own codec.
ZarrV3ChunkGridField
module-attribute
¶
ZarrV3ChunkGridField = TypeAliasType(
"ZarrV3ChunkGridField", ZarrV3MetadataFieldJSON
)
A member that holds a chunk grid: a document's chunk_grid.
ZarrV3ChunkKeyEncodingField
module-attribute
¶
ZarrV3ChunkKeyEncodingField = TypeAliasType(
"ZarrV3ChunkKeyEncodingField", ZarrV3MetadataFieldJSON
)
A member that holds a chunk key encoding: a document's chunk_key_encoding.
ZarrV3CodecField
module-attribute
¶
ZarrV3CodecField = TypeAliasType(
"ZarrV3CodecField", ZarrV3MetadataFieldJSON
)
A member that holds a codec. A document's codecs is tuple[ZarrV3CodecField, ...], and so is a shard's.
ZarrV3DataTypeField
module-attribute
¶
ZarrV3DataTypeField = TypeAliasType(
"ZarrV3DataTypeField", ZarrV3MetadataFieldJSON
)
A member that holds a data type: a document's data_type, or a struct field's data type. It is read in the same scope as the object that contains it.
ZarrV3Kind
module-attribute
¶
ZarrV3Kind: TypeAlias = (
DataTypeDefinition[Any]
| ChunkGridDefinition[Any]
| ChunkKeyEncodingDefinition[Any]
| CodecDefinition[Any]
| StorageTransformerDefinition[Any]
| ArrayExtraFieldDefinition[Any]
| GroupExtraFieldDefinition[Any]
)
A definition of a kind of v3 field.
ZarrV3StaticCodecField
module-attribute
¶
ZarrV3StaticCodecField = TypeAliasType(
"ZarrV3StaticCodecField", ZarrV3MetadataFieldJSON
)
A member that holds a codec with a static encoded size. A shard's index_codecs uses
this, because a reader locates the index from a size it knows before reading it.
ZarrV3StorageTransformerField
module-attribute
¶
ZarrV3StorageTransformerField = TypeAliasType(
"ZarrV3StorageTransformerField", ZarrV3MetadataFieldJSON
)
A member that holds a storage transformer. A document's storage_transformers is tuple[ZarrV3StorageTransformerField, ...].
ArrayExtraFieldDefinition
dataclass
¶
Bases: ExtraFieldDefinition[C]
An extra field of a v3 array document: a member the spec does not define, read by its key.
Source code in src/zarr_metadata/v3/_definition.py
label
class-attribute
¶
label: str = 'array extra field'
The name of the kind in error messages, for example "codec".
spec_members
class-attribute
¶
spec_members: frozenset[str] = frozenset(
typeddict_keys(ZarrV3ArrayMetadataJSON).members
)
The members the spec defines in a document this kind reads extra fields of, which are never extra fields.
Chunk
dataclass
¶
The input a codec receives: chunks with given lengths along each axis, and a data type.
Unknown parts are None. This includes the lengths along an axis that
the grid does not declare, and every part of the chunk output by a
codec that does not declare its output. A data type field that the
scope did not read is kept as written, and it also says nothing about
the values. A codec's chunk rules check only what is known, so a chunk
with nothing known about it, Chunk(), never causes a problem.
Source code in src/zarr_metadata/v3/_definition.py
data_type
class-attribute
instance-attribute
¶
data_type: ResolvedField[DataTypeDefinition[Any]] | None = (
None
)
The data type field of the values, as a scope read it. None when no field declares the data type: a document with no data type (its reading holds UNSET) passes the pipeline a chunk of unknown type.
ChunkGridDefinition
dataclass
¶
Bases: Definition[C]
A chunk grid, and the array shapes it fits.
shape_rules yields the spec violations in a grid with this
configuration over an array of a given shape, such as a dimension with
no chunk length, or chunks that do not cover the dimension. It receives
the configuration, the nested fields as the scope read them, and the
shape, and it locates its problems in the configuration. A grid that
does not declare shape rules fits every shape.
chunk_lengths determines what the first codec of the array's
pipeline receives: the lengths of the grid's chunks along each axis of
an array whose shape the grid fits. A regular grid has one length per
axis, and a rectilinear grid has every length it lists. It is called
only for a grid that its shape rules accept. A grid that does not
declare it leaves the lengths along every axis unknown.
Source code in src/zarr_metadata/v3/_definition.py
chunk_lengths
class-attribute
instance-attribute
¶
The lengths of the chunks along each axis of an array whose shape the grid fits; None where unknown.
field_aliases
class-attribute
¶
field_aliases: tuple[TypeAliasType, ...] = (
ZarrV3ChunkGridField,
)
The field aliases used to annotate a configuration member that holds a field of this kind. For a codec: ZarrV3CodecField and ZarrV3StaticCodecField.
ChunkKeyEncodingDefinition
dataclass
¶
Bases: Definition[C]
A chunk key encoding.
Source code in src/zarr_metadata/v3/_definition.py
field_aliases
class-attribute
¶
field_aliases: tuple[TypeAliasType, ...] = (
ZarrV3ChunkKeyEncodingField,
)
The field aliases used to annotate a configuration member that holds a field of this kind. For a codec: ZarrV3CodecField and ZarrV3StaticCodecField.
CodecDefinition
dataclass
¶
Bases: Definition[C]
A codec: what it converts its input to, and whether the size of its output is static.
A codec that receives an array (array -> array, array -> bytes)
declares the spec violations for a given input Chunk with
chunk_rules. It receives the configuration, the nested fields as the
scope read them, and the chunk, and it locates its problems in the
configuration. For example, a bytes codec without endian that
receives a multi-byte data type is a problem. An array -> array codec
also declares its output with transition: given its input chunk, it
returns the chunk the next codec receives. For example, transpose
permutes the axes, and cast_value changes the data type. These two
functions correspond to the spec: a codec computes its output from the
shape and data type of its input, and "If the
decoded_representation_type is not supported, this algorithm must
fail with an error"
(https://github.com/zarr-developers/zarr-specs/blob/fc7dd9c9beb5a50b87f9b08b00bf50fc0048482f/docs/v3/core/index.rst#L987-L994).
The transition is called for every input chunk, whatever the chunk
rules found, so it must return only what is true in either case. For
example, a transpose whose order has the wrong number of axes
passes on unknown lengths. A codec that does not declare its output
passes the next codec a chunk with nothing known about it.
A codec that contains its own pipelines declares what each one
receives with pipelines. Given the codec's input chunk, it returns
the chunk that the first codec of each pipeline receives, keyed by the
configuration member that holds the pipeline. For example, a shard's
inner codecs receive its inner chunks, and its index codecs receive
the shard index. Like the transition, it is called whatever the chunk
rules found, and must return only what is true in either case. A
function that is never called for a codec of its kind is rejected,
such as the chunk rules of a bytes -> bytes codec, which receives
bytes.
Source code in src/zarr_metadata/v3/_definition.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
chunk_rules
class-attribute
instance-attribute
¶
chunk_rules: Callable[
[C, Nested, Chunk], Iterable[ValidationProblem]
] = no_rules
The spec violations for this codec with a given input chunk, located in the configuration.
field_aliases
class-attribute
¶
field_aliases: tuple[TypeAliasType, ...] = (
ZarrV3CodecField,
ZarrV3StaticCodecField,
)
The field aliases used to annotate a configuration member that holds a field of this kind. For a codec: ZarrV3CodecField and ZarrV3StaticCodecField.
label
class-attribute
¶
label: str = 'codec'
The name of the kind in error messages, for example "codec".
pipelines
class-attribute
instance-attribute
¶
The chunk each contained pipeline receives, keyed by the configuration member that holds the pipeline.
DataTypeDefinition
dataclass
¶
Bases: WithFillValue[C]
A data type, and the fill value of an array with that data type.
fill_value is the JSON shape of a fill value, such as
Int8FillValue. It is an annotation that the checker reads the same
way it reads a configuration's members, including any range.
fill_value_rules yields the spec violations in a fill value of that
shape that the type cannot express, such as a hex string of the wrong
width.
The rules receive the configuration, the nested fields as the scope
read them (a struct's field types), and the typed fill value. A data
type that does not declare its fill value accepts any JSON.
fill_value_canonical writes a fill value without problems (well
typed and allowed by the rules) in the single canonical spelling of
its value. So two fill values are the same value of the type exactly
when their canonical spellings are written the same way: "NaN" and
"0x7fc00000" are the same float32, but 0.0 and -0.0 are two
different values. It receives the same arguments as the rules. A data
type that does not declare it has one spelling per value: the value as
written.
storage declares how the values are stored: in single bytes, in
several bytes at a time, or each value in as many bytes as it needs.
The bytes codec uses this to decide whether the data type it
receives needs an endian (it does for multi-byte numbers). A
struct's storage depends on its fields, so storage receives the
nested fields as the scope read them. A data type that does not
declare it leaves its storage unknown.
A data type named the way a document writes raw bits of one size (such
as r16) is rejected. That name is read as r*, so this definition
would never be used.
Source code in src/zarr_metadata/v3/_definition.py
field_aliases
class-attribute
¶
field_aliases: tuple[TypeAliasType, ...] = (
ZarrV3DataTypeField,
)
The field aliases used to annotate a configuration member that holds a field of this kind. For a codec: ZarrV3CodecField and ZarrV3StaticCodecField.
label
class-attribute
¶
label: str = 'data type'
The name of the kind in error messages, for example "codec".
storage
class-attribute
instance-attribute
¶
storage: Callable[[C, Nested], StorageClass | None] = (
unknown_storage
)
How the values are stored, given the configuration and the nested fields; None when unknown.
ExtraFieldDefinition
dataclass
¶
Bases: Definition[C]
A member of a v3 document that the spec does not define, an extra field: its name is the member's key, and its configuration is the member's value.
This is not a kind. ArrayExtraFieldDefinition and
GroupExtraFieldDefinition are, because one key may mean different
things in an array document and in a group document. An extra field is
not one of the spec's extension points, and no registry names it, so
any key may name one. As a field it is written as the member alone,
{key: value}, and it is located at the member's key. A definition
reads a member whose value is an object. A member that no definition
in scope claims is not read: a reader keeps it as it is written, and
lists it in must_understand_fields unless it says
"must_understand": false.
finite says whether every number in the member must be finite, as
RFC 8259 JSON requires. A member that holds user data sets it to
False: consolidated metadata holds node documents, whose attributes
may hold NaN, Infinity and -Infinity. A member that nothing
claims is not read, so like attributes it may hold any number.
The spec lets every extension member carry "must_understand": false,
which tells a reader that does not understand the member that it may
ignore it. So the configuration declares must_understand, and a
definition whose configuration does not is refused. A member the spec
defines, such as an array's shape, is never an extra field, and a
definition named after one is refused too.
Source code in src/zarr_metadata/v3/_definition.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | |
GroupExtraFieldDefinition
dataclass
¶
Bases: ExtraFieldDefinition[C]
An extra field of a v3 group document: a member the spec does not define, read by its key. consolidated_metadata is one.
Source code in src/zarr_metadata/v3/_definition.py
label
class-attribute
¶
label: str = 'group extra field'
The name of the kind in error messages, for example "codec".
spec_members
class-attribute
¶
spec_members: frozenset[str] = frozenset(
typeddict_keys(ZarrV3GroupMetadataJSON).members
)
The members the spec defines in a document this kind reads extra fields of, which are never extra fields.
Stage
dataclass
¶
One codec of a pipeline, and the chunk it receives.
Source code in src/zarr_metadata/v3/_pipeline.py
codec
instance-attribute
¶
codec: ResolvedField[CodecDefinition[Any]]
The codec, as the scope read it.
StorageTransformerDefinition
dataclass
¶
Bases: Definition[C]
A storage transformer.
Source code in src/zarr_metadata/v3/_definition.py
field_aliases
class-attribute
¶
field_aliases: tuple[TypeAliasType, ...] = (
ZarrV3StorageTransformerField,
)
The field aliases used to annotate a configuration member that holds a field of this kind. For a codec: ZarrV3CodecField and ZarrV3StaticCodecField.
ZarrV3Context ¶
A scope that reads Zarr v3 documents. Every v3 reader takes one.
It implements Context, and has one slot for each kind of field a v3
document holds, as ZarrV3ContextSlots declares them. The slots for
the spec's extension points are named like the document member that
holds such fields: data_types, chunk_grids, chunk_key_encodings,
codecs and storage_transformers. array_extra_fields and
group_extra_fields hold the definitions of members the spec does not
define, by key. Each slot is a read-only mapping from the name each
definition is filed under (r* for raw bits) to the definition. The
constructor and update take, for each slot, an iterable of
definitions or such a mapping, so one scope's slot can be given to
another. A definition of another kind than its slot holds, and a key
that is not its definition's name, raise TypeError, and two
different definitions under one name in a slot raise
ScopeConflictError. To replace a definition, or a whole slot, use
update.
ZarrV3Context() is the scope that claims nothing. Two scopes are
equal when they file the same definitions in each slot, and equal
scopes have equal hashes.
Source code in src/zarr_metadata/v3/_context.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
array_extra_fields
property
¶
array_extra_fields: Mapping[
str, ArrayExtraFieldDefinition[Any]
]
The definitions of members of an array document that the spec does not define, by key.
chunk_grids
property
¶
chunk_grids: Mapping[str, ChunkGridDefinition[Any]]
The chunk grid definitions in scope, by name.
chunk_key_encodings
property
¶
chunk_key_encodings: Mapping[
str, ChunkKeyEncodingDefinition[Any]
]
The chunk key encoding definitions in scope, by name.
codecs
property
¶
codecs: Mapping[str, CodecDefinition[Any]]
The codec definitions in scope, by name.
data_types
property
¶
data_types: Mapping[str, DataTypeDefinition[Any]]
The data type definitions in scope, by the name each is filed under (r* for raw bits).
group_extra_fields
property
¶
group_extra_fields: Mapping[
str, GroupExtraFieldDefinition[Any]
]
The definitions of members of a group document that the spec does not define, by key.
kinds
class-attribute
¶
kinds: Mapping[str, type[ZarrV3Kind]] = slot_kinds(
ZarrV3ContextSlots, is_v3_kind
)
The kind of definition each slot holds, by slot, as ZarrV3ContextSlots declares them.
storage_transformers
property
¶
storage_transformers: Mapping[
str, StorageTransformerDefinition[Any]
]
The storage transformer definitions in scope, by name.
zarr_format
property
¶
zarr_format: Literal[3]
The Zarr format of the documents this scope reads: 3.
claimant ¶
The definition of kind in scope that reads name (a name as a document uses it), or None if there is none. Raises TypeError for a kind of the other format.
This is the definition filed under the name that filed_under
maps name to. That is name itself, except for raw bits, where
r16 is read by the definition of r*.
Source code in src/zarr_metadata/v3/_context.py
definitions_of ¶
The definitions of kind in scope, by the name each is filed under: the slot that holds kind. Raises TypeError for a kind of the other format.
Source code in src/zarr_metadata/v3/_context.py
union ¶
union(*others: ZarrV3Context) -> ZarrV3Context
The smallest scope that files everything this scope and each of others file.
Raises ScopeConflictError when two of them file different
definitions under one name in a slot. To replace a definition on
purpose, use update. Raises TypeError for a scope of another
format.
Source code in src/zarr_metadata/v3/_context.py
update ¶
update(
**slots: Unpack[ZarrV3ContextSlots],
) -> ZarrV3Context
This scope, with each slot given here holding only the definitions given for it. The other slots are kept.
A slot can be given as a mapping from each definition's name to
it, so a slot of this scope passes back in changed:
context.update(codecs={**context.codecs, "gzip": MY_GZIP})
replaces the gzip definition and keeps the other codecs, and
context.update(codecs=[*context.codecs.values(), MY_CODEC]) adds
one, raising ScopeConflictError if the scope already files
another definition under its name.
Source code in src/zarr_metadata/v3/_context.py
ZarrV3ContextSlots ¶
Bases: TypedDict
The definitions in each slot of a v3 scope, as ZarrV3Context and its update take them.
This is where a v3 scope's slots are declared: each key is a slot,
and its value the definitions of the kind that slot holds, as an
iterable of them or as a mapping from each one's name to it.
ZarrV3Context.kinds is read from these annotations, so a type
checker checks every slot a caller names, and every definition given
in it.
Source code in src/zarr_metadata/v3/_context.py
array_extra_fields
instance-attribute
¶
array_extra_fields: (
Iterable[ArrayExtraFieldDefinition[Any]]
| Mapping[str, ArrayExtraFieldDefinition[Any]]
)
Members of an array document that the spec does not define, by key.
chunk_grids
instance-attribute
¶
chunk_grids: (
Iterable[ChunkGridDefinition[Any]]
| Mapping[str, ChunkGridDefinition[Any]]
)
Chunk grids, read from chunk_grid.
chunk_key_encodings
instance-attribute
¶
chunk_key_encodings: (
Iterable[ChunkKeyEncodingDefinition[Any]]
| Mapping[str, ChunkKeyEncodingDefinition[Any]]
)
Chunk key encodings, read from chunk_key_encoding.
codecs
instance-attribute
¶
codecs: (
Iterable[CodecDefinition[Any]]
| Mapping[str, CodecDefinition[Any]]
)
Codecs, read from codecs and from the codecs a codec holds.
data_types
instance-attribute
¶
data_types: (
Iterable[DataTypeDefinition[Any]]
| Mapping[str, DataTypeDefinition[Any]]
)
Data types, read from data_type.
group_extra_fields
instance-attribute
¶
group_extra_fields: (
Iterable[GroupExtraFieldDefinition[Any]]
| Mapping[str, GroupExtraFieldDefinition[Any]]
)
Members of a group document that the spec does not define, by key.
storage_transformers
instance-attribute
¶
storage_transformers: (
Iterable[StorageTransformerDefinition[Any]]
| Mapping[str, StorageTransformerDefinition[Any]]
)
Storage transformers, read from storage_transformers.
storage_of ¶
storage_of(
data_type: ResolvedField[DataTypeDefinition[Any]],
) -> StorageClass | None
How the values of data_type (a data type field a scope read) are stored; None when unknown.
The storage is unknown when the scope did not read the data type, or
its definition does not declare storage. The definition's storage is
the extension author's code. Its result is checked to be a storage
class. If it raises an error, a note is added that says which data
type's storage raised it.