Skip to content

chunkmirage materialize: a dataset written to a store as the server serves it - #40

Merged
davidackerman merged 2 commits into
mainfrom
feature/materialize-python
Oct 16, 2026
Merged

davidackerman merged 2 commits into
mainfrom
feature/materialize-python

Conversation

@davidackerman

Copy link
Copy Markdown
Member

The Python side of #39's Engine.materialize: a dataset, or a box of it, computed and written into a store as a frontend serves it, so it reads back as a stored dataset of its own. registration-station's use is the first: a pass computed once per round (about 5 minutes for the s3 stage on an A100), then read from disk instead of computed again.

chunkmirage materialize SOURCE OUT [--op ...] [--format zarr3|zarr|n5] [--level N ...] [--box lo:hi]

and chunkmirage.materialize(pipeline, where, format=, levels=, box=, compressor=, skip_empty=, progress=) for any pipeline, a chain of datasets through dataset:// among them (registry.get(name)).

What it writes. The frontend's own metadata and encoded chunks (resolve and encode, as the server answers a request), so a zarr v3 (OME-Zarr 0.5), zarr v2 (OME-Zarr 0.4, consolidated) or N5 store is byte for byte what a client fetches, compressed as the server compresses (blosc for zarr, gzip for N5, --compressor otherwise). Frontends gain chunk_key(level, index), the path a chunk is served at; the precomputed and mesh frontends have none, so they are not offered. The store is anything tensorstore's kvstore writes: a directory, or a file://, gs:// or s3:// URL.

In what order. Every level's metadata first, so a store whose writing stopped part way is still the dataset, zero where no chunk was written yet; then the chunks of the levels asked for (all by default), in batches of 256 computed at once through #38's demand.gather; a chunk of nothing but zeros is left out (a reader takes a missing chunk as the fill value) unless --keep-empty. --box takes level 0's voxels along the last axes, and each level writes the same region on its own voxels, rounded out to whole chunks.

Not here. The browser's background class (#39) matters only when a region is written inside a server someone is browsing; a write from the command line or a script needs none, and inside a running server this competes with clients as any work asked for from Python does (never dropped, in arrival order), its chunks passing through the server's cache. The cache on disk that browsing fills (roadmap item 2) is still to do.

Tests (tests/test_materialize.py, 4): a warp shifted past its image's edge written as zarr v3, zarr v2 and N5, every chunk counted written or skipped (the ones past the edge skipped) and each level read back with the served shape, voxel size, dtype and values; and from the command line, a box of level 1 only, one chunk written and the rest of the store zeros.

Docs: concepts/formats.md (a section beside the browser engine's), reference/cli.md (the command), reference/api.md, design.md (the core's table), contributing.md (the plugin API), roadmap.md (item 2: a first piece in both engines), CHANGELOG.md. Checks: pytest (322 passed), ruff, mkdocs build --strict; chunkmirage schema unchanged; web/ untouched.

#39's Engine.materialize: a pipeline, or a box of it, computed and written into a store (a directory, file://, gs:// or s3://, through tensorstore's kvstore) as a frontend serves it, zarr v3 with OME-Zarr 0.5, zarr v2 with OME-Zarr 0.4 (consolidated) or N5, the metadata and each chunk byte for byte what a client fetches, so the store reads back as a stored dataset of its own (a registration's pass computed once, then read from disk); every level's metadata first, so a store stopped part way is still the dataset, then the chunks of the levels asked for, several at once (demand.gather, in batches), those of nothing but zeros left out unless asked for; --box takes level 0's voxels along the last axes and every level writes the same region rounded out to whole chunks; frontends say where a chunk is served (chunk_key: zarr3, zarr2 and N5); the tests write all three formats and read them back as they were served, and a box of one level from the command line; docs: formats (a section beside the browser engine's), CLI and API references, design's core table, contributing's plugin API, the roadmap's item 2 (a first piece in both engines), CHANGELOG
@davidackerman
davidackerman merged commit ad8f2a0 into main Oct 16, 2026
2 checks passed
@davidackerman
davidackerman deleted the feature/materialize-python branch October 16, 2026 18:05
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