Skip to content

feat(context): scope ArrayIO's extension resolution with a Context - #420

Draft
d-v-b wants to merge 1 commit into
claude/arrayio-lazy-metadata-48d8e5from
claude/arrayio-context
Draft

d-v-b wants to merge 1 commit into
claude/arrayio-lazy-metadata-48d8e5from
claude/arrayio-context

Conversation

@d-v-b

@d-v-b d-v-b commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

Added a context to zarr.ArrayIO and zarr.AsyncArrayIO: a value defining the data types, codecs and codec pipeline in scope for one array. Extension names in a stored document or in build's keyword arguments resolve through the context instead of the default registries; a kind the context leaves unset falls back to the defaults, while a kind it sets is a closed world, and a name outside it fails to resolve with an error naming the scope.

The type is the existing zarr.core.context.Context — the extensions-in-scope value the structured data type resolution already threads through nested reads — extended with codecs: Mapping[str, type[Codec]] and codec_pipeline: type[CodecPipeline], and exported from zarr.experimental (the ArrayIO classes themselves are public in the zarr namespace). An optional context= is threaded through the resolution functions: parse_dtype and the data-type getters, codec normalization (_resolve_codec, _parse_*_codec, parse_codecs), from_dict on both metadata classes, parse_array_metadata, create_codec_pipeline, and build_array_metadata. With no context, every path is byte-identical to before.

The layering and the document-model binding land in #419; this PR only adds the context. With the document-first binding the context is consumed only where the document resolves into classes, so opening an array whose codec names fall outside the context still works for document operations, and resolution fails when the data path is built.

Scope notes:

  • Zarr format 2 filters and compressors are numcodecs objects, resolved by numcodecs; no context governs them (documented on from_dict and build_array_metadata).
  • Codec instances pass through any context: it scopes name resolution, not values.
  • Chunk key encodings and chunk grids are not yet context kinds; they can be added when their registries become extension points.
Stack

Stacked on #419 (claude/arrayio-lazy-metadata-48d8e5); merge that first. This PR is the claude/arrayio-context branch.

🤖 Generated with Claude Code

d-v-b added a commit that referenced this pull request Oct 29, 2026
Assisted-by: ClaudeCode:claude-fable-5
@d-v-b
d-v-b force-pushed the claude/arrayio-context branch 3 times, most recently from 89fa080 to be7fcdc Compare October 29, 2026 12:28
@d-v-b d-v-b changed the title feat(experimental): scope ArrayIO's extension resolution with a Context feat(context): scope ArrayIO's extension resolution with a Context Oct 29, 2026
Extends zarr.core.context.Context — the extensions-in-scope value the
structured data type resolution already uses — with codecs and
codec_pipeline, and threads an optional context through the resolution
functions: parse_dtype and the data-type getters, codec normalization
(_resolve_codec, _parse_*_codec, parse_codecs), metadata from_dict on
both formats, parse_array_metadata, create_codec_pipeline, and
build_array_metadata. A kind the context leaves None resolves from the
default registries exactly as before; a kind it sets is a closed world,
and a name outside it fails to resolve, naming the scope.

ArrayIO and AsyncArrayIO take the context in build, open and their
constructors, and AsyncArray passes one through to the AsyncArrayIO it
wraps. With the document-first binding the context is consumed only
where the document resolves into classes: opening an array whose codec
names fall outside the context still works for document operations, and
resolution fails when the data path is built.

Refs zarr-developers#4217

Assisted-by: ClaudeCode:claude-fable-5
@d-v-b
d-v-b force-pushed the claude/arrayio-context branch from be7fcdc to 6e91402 Compare October 29, 2026 13:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant