Skip to content

Workaround for KeyError 'ome' when writing multiscale images#1115

Merged
LucaMarconato merged 3 commits intomainfrom
workaround/issue-1024
May 5, 2026
Merged

Workaround for KeyError 'ome' when writing multiscale images#1115
LucaMarconato merged 3 commits intomainfrom
workaround/issue-1024

Conversation

@LucaMarconato
Copy link
Copy Markdown
Member

Closes #1024

Re-open the zarr group after da.compute() in _write_raster_datatree so that the main process picks up metadata written by ome-zarr-py's delayed write_multiscales_metadata() task, which runs in a subprocess under the 'processes' scheduler and leaves the original in-memory GroupMetadata stale. The fresh group is returned to _write_raster so the subsequent spatialdata attrs write also uses the correct on-disk state.

Added tests.

Upstream issue: ome/ome-zarr-py#580

…sses scheduler (#1024)

Re-open the zarr group after da.compute() in _write_raster_datatree so
that the main process picks up metadata written by ome-zarr-py's delayed
write_multiscales_metadata() task, which runs in a subprocess under the
'processes' scheduler and leaves the original in-memory GroupMetadata stale.
The fresh group is returned to _write_raster so the subsequent spatialdata
attrs write also uses the correct on-disk state.

Upstream issue: ome/ome-zarr-py#580

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LucaMarconato LucaMarconato marked this pull request as ready for review May 5, 2026 12:39
LucaMarconato and others added 2 commits May 5, 2026 14:51
The re-open after da.compute() was inheriting stale consolidated metadata,
which caused KeyError when newly written children (e.g. labels3d_multiscale_xarray)
were not yet reflected in it. Passing use_consolidated=False forces zarr to
read group membership directly from the store instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.93%. Comparing base (8d7f72f) to head (b12778d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1115   +/-   ##
=======================================
  Coverage   91.93%   91.93%           
=======================================
  Files          51       51           
  Lines        7772     7774    +2     
=======================================
+ Hits         7145     7147    +2     
  Misses        627      627           
Files with missing lines Coverage Δ
src/spatialdata/_io/io_raster.py 92.17% <100.00%> (+0.08%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaMarconato LucaMarconato merged commit aa58ffa into main May 5, 2026
12 checks passed
@LucaMarconato LucaMarconato deleted the workaround/issue-1024 branch May 5, 2026 13:23
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.

Writing multiscale element to disk fails when configuring Dask to uses "processes"

1 participant