fix(writers): let continued and extended runs grow the OME-Zarr time axis - #26
Open
hinderling wants to merge 2 commits into
Open
fix(writers): let continued and extended runs grow the OME-Zarr time axis#26hinderling wants to merge 2 commits into
hinderling wants to merge 2 commits into
Conversation
…axis The single-position ome-writers stream was created with a fixed time count taken from the first run, so every frame appended by continue_experiment or extend_experiment failed with "Cannot append frame: would exceed total of N frames" and was only logged as a background error. The stream now declares an unbounded time axis (ome-writers grows it with amortised resizes and closes at the exact written length), and the controller calls the writer's existing but uncalled set_n_timepoints on continue/extend so the multi-position path pre-sizes once. Regression test continues a single-position OME-Zarr run and checks the store. Claude-Session: https://claude.ai/code/session_01CSrNm4WLiNzDkiCi75vZfy
hinderling
marked this pull request as draft
September 9, 2026 12:26
…can grow Route the single-position OmeZarrWriter through the same direct zarr-python path as multi-position runs instead of an ome-writers stream. The stream could not be continued: a bounded time axis refuses appends past the declared count, and an unbounded one (ome-writers <= 0.3.2) grows by one timepoint per frame, rewriting the array's zarr.json on every write, which is the slow, crash-fragile pattern on SMB shares the direct path was built to avoid. The direct path pre-sizes to n_timepoints, grows once per continued/extended batch via set_n_timepoints, and trims to the written length on close. On-disk layout is unchanged ((t, c, y, x) at root "0"); the array now also carries dimension_names as the stream did. set_n_timepoints takes the label lock, matching _maybe_resize_leading. OmeZarrWriterPlate is untouched and still cannot be continued. Tests: writer-level continue past the declared length for one and two positions, asserting no per-frame metadata rewrite; extend_experiment variant of the single-position integration test.
hinderling
marked this pull request as ready for review
September 9, 2026 13:50
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.
Problem
A single-position OME-Zarr run cannot be continued or extended. The ome-writers stream was created with a fixed time count taken from the first run's events, so every frame appended by
continue_experimentorextend_experimentfailed inside the writer withand was only logged as a background error, so the run reported success while the continued frames were missing from the store. This has been the case since the OME-Zarr writers were added (2026-04-02);
continue_experimentpredates them.Fix
OmeZarrWriter: single-position runs now build the raw array directly with zarr-python, the same path multi-position runs already use. The ome-writers stream is gone from the base class. Rationale: a bounded stream cannot grow, and an unbounded one (ome-writers ≤ 0.3.2) grows by exactly one timepoint per frame, rewriting0/zarr.jsonon every write — the slow, crash-fragile pattern on SMB shares the direct path was built to avoid. The direct path pre-sizes ton_timepoints, grows once per appended batch, and trims to the written length on close.0, axes(t, c, y, x), same multiscales/omero metadata. The array now also carriesdimension_names, as the stream did.Controller:continue_experimentandextend_experimentcall the writer'sset_n_timepoints, so the time axis is resized once per batch instead of per frame.set_n_timepointstakes the label lock, matching_maybe_resize_leading.TestContinueExperimentOmeZarrcovers continue and extend end to end on a single position;TestOmeZarrContinuePastDeclared(writer level, 1 and 2 positions) continues past the declared length and asserts the array metadata is not rewritten by the appended frames.Not in this PR
OmeZarrWriterPlatestill streams raw frames through a bounded ome-writers stream and cannot be continued or extended (sameIndexError). Left untouched on purpose; theset_n_timepointsdocstring says so. Whether to fix it, move plate layout to an export/viewer step, or retire it is a separate decision.Notes
The examples PR #27 (
feat/examples) has a demo that continues a run and depends on this; merge this one first. Writer and continue tests pass locally (Motile-parametrized cases deselected; the venv still has motile 0.4, the code needs ≥1.0). A real single-FOV run on the scope is the confirmation that matters.