Repository navigation
Conversation
d-v-b
added a commit
that referenced
this pull request
Oct 29, 2026
Assisted-by: ClaudeCode:claude-fable-5
d-v-b
force-pushed
the
claude/arrayio-context
branch
3 times, most recently
from
October 29, 2026 12:28
89fa080 to
be7fcdc
Compare
d-v-b
force-pushed
the
claude/arrayio-context
branch
9 times, most recently
from
October 31, 2026 16:56
e2bcdc9 to
45896a5
Compare
d-v-b
force-pushed
the
claude/arrayio-context
branch
2 times, most recently
from
November 2, 2026 13:49
2e180d6 to
8c3d1ee
Compare
d-v-b
force-pushed
the
claude/arrayio-context
branch
2 times, most recently
from
November 11, 2026 20:12
6bc8923 to
de542a7
Compare
d-v-b
added a commit
that referenced
this pull request
Nov 11, 2026
Each new branch or call that #420 adds inside a routine #419 already has now says what it is for: the registry or codec scope a context selects, the constructor keyword passed only when a context is given, the pipeline kept only while its class is, codecs read again in a closed scope, and the scoped-or-default reads before a chunk write. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Extends zarr.core.context.Context (exported as zarr.experimental.Context) with `codecs` and `codec_pipeline`, makes `data_types` optional, and threads an optional context through data type and codec resolution, both formats' metadata `from_dict`, `parse_array_metadata`, the per-format builders, the repair check before chunk writes, and ArrayIO/AsyncArrayIO/AsyncArray (with `with_context`). A kind the context leaves unset resolves from the defaults; a kind it sets is a closed world over top-level names (`limits_names`), checking instances, structured dtypes' fields and default codec chains as well as names, and re-resolving only the kinds it limits. A context that only selects the pipeline, or sets nothing, resolves as no context does. The context's pipeline choice fills the slot the global configuration fills otherwise, so the context is the per-binding replacement for that global state. Bindings keep their context through derivation, AsyncArray's pickled state, with_config and dataclasses.replace, and compare it in equality; the pipeline-parity, indexing and fork-pool tests select their pipeline through a context instead of global configuration. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`zarr.core.dtype` imports `zarr.core.context` (its registry and structured data type read with a `Resolver`), and `zarr.registry` imports `zarr.core.dtype`, so `zarr.core.context` cannot import either at module level. Its four deferred imports of the default data type registry are now one, in `_default_data_types`, and each import that stays deferred says why. The test that patches the context module imports it at the top. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each new branch or call that #420 adds inside a routine #419 already has now says what it is for: the registry or codec scope a context selects, the constructor keyword passed only when a context is given, the pipeline kept only while its class is, codecs read again in a closed scope, and the scoped-or-default reads before a chunk write. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Context's scope rule was checked separately on each route that resolves names (document reads, builders, metadata entering or leaving a scope, the codecs fitting rebuilds), and the routes drifted: the same document and context could fail with different errors, or pass on one route and fail on another, depending on the order each route checked in. Codec names now resolve only in `_resolve_codec`, and an instance is held to a scope only by `_codec_in` (refused for a builder, resolved from its JSON for metadata already resolved). Data types resolve only in `get_data_type_from_json`, and instances only through `_data_type_in`. Under a closed scope the resolver checks that what it built reads back there: of the class its written name resolves to, reading the JSON it writes. `_checked_in_scope` and `_reread_in_defaults` become one `_resolved_again`. Two property tests pin the invariants the earlier per-route fixes chased: every route reaches the same outcome for a document and a context, and what a context declares stores and reopens under it with the same classes and data. Assisted-by: ClaudeCode:claude-opus-5-5
Context scopes wait for the release that makes the binding layer public. The review of the single-resolver refactor left one Medium and four Low findings; each is now a strict-xfail test, so fixing one announces itself. The property tests gain a data type variant that cannot read back, which catches deleting the data type read-back check; nothing caught that before. proposals/context-scopes-parked.md lists the findings, the shared fix for M1 and L1, the open decisions, and how to pick the branch up. Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
d-v-b
force-pushed
the
claude/arrayio-context
branch
from
November 16, 2026 09:03
7d55d8e to
cf22233
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Added a
context(zarr.experimental.Context) tozarr.ArrayIOandzarr.AsyncArrayIO: a value defining the data types, codecs and codec pipeline in scope for one array. Extension names in a stored document or in creation 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 (for codecs, with an error naming the codecs in scope). The codec scope governs Zarr format 3 codecs; a Zarr format 2 array's filters and compressor are numcodecs objects, which no context governs.AsyncArray.contextgives an array's context (Array.io.contextfor a synchronous array), andwith_contextrebinds one array under another scope, so tests and applications select a codec pipeline per binding instead of through the global configuration; the pipeline-parity tests now run that way.Without a context, every binding uses the default registries and the globally configured pipeline, exactly as before: the context is the explicit, per-binding replacement for that global state, and the path to deprecating it.
The scope governs top-level names: codecs nested inside a
sharding_indexedcodec resolve through the default registry today.with_contextre-resolves metadata that was already resolved, so a stored name outside the new scope fails there too; a binding opened from the store resolves no names until its data path is built, so it fails there.Summary (agent)
zarr.core.context.Context, the extensions-in-scope value structured data type resolution already threads through nested reads, extended withcodecs: Mapping[str, type[Codec]]andcodec_pipeline: type[CodecPipeline]and exported fromzarr.experimental.context=is threaded throughparse_dtypeand the data type getters,parse_codecs,from_dict/_read_storedon both metadata classes,parse_array_metadata,parse_stored_array, andbuild_array_metadata_v2/build_array_metadata_v3. The binding passes the context's pipeline class (or the configured one) tocreate_codec_pipeline.with_contextcompletes thewith_*family. The pipeline-parity, sharded-indexing-rejection and fork-pool tests now select their pipeline withwith_contextinstead of settingcodec_pipeline.path._resolve_codecand_codec_infor codecs,get_data_type_from_jsonand_data_type_infor data types, and_resolved_againfor metadata entering or leaving a scope. Before this, each route (document reads, builders,with_context, the codecs fitting rebuilds) checked the scope rule itself, and the same document and context could pass on one route and fail on another.Design notes (agent)
zarr.core.contextkeeps three function-local imports, each commented:zarr.core.dtypeimports the context module, andzarr.registryimportszarr.core.dtype, so neither can be imported at its top. The cycle predates this PR (main defers the same import inContext.default).Test notes (agent)
tests/test_context_properties.pyholds two property tests for the invariants the resolvers keep: every route reaches the same outcome for a document and a context, and what a context declares stores and reopens under it with the same classes and data.from_dictdoes not raise, not which class it builds.with_context(None)) raises a bareTypeErrorwhere opening the stored document with no context raisesMetadataValidationError.parse_dtype's JSON branch swallows the data type read-back error and reports a misleading native-dtype error.proposals/context-scopes-parked.mdlists these, two findings without a test (short-hand codec names from fix(metadata): read Zarr V3.1 short-hand extension names zarr-developers/zarr-python#4506 need handling in_resolve_codecon the next rebase onto main; a docstring that overstates_resolve_codec's reach), and the decisions still open.tools/compat(from feat(array): add ArrayIO and AsyncArrayIO, the explicit-IO layer under Array and AsyncArray #419) was last run against this branch at 7d55d8e, before the rebase and the resolver refactor; it has not been rerun on the current head.Stack (agent)
Stacked on #419 (
claude/arrayio-lazy-metadata-48d8e5), rebased onto its head ef0dbd8; merge that first. This PR is theclaude/arrayio-contextbranch.This branch is parked.
proposals/arrayio-internal-first.md(a draft plan; nothing in it is implemented) proposes shipping the binding layer as private internals in one release and making it public, together withContextscopes, in the next. Under that plan this PR waits for the second release, andproposals/context-scopes-parked.mdsays how to pick it up.🤖 Generated with Claude Code