scverse / scverse/spatialdata

[Request] More informative error message when len nodes != 1

Open
#237 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
394
Forks
95
Avg merge
4d 3h
Merged PRs (30d)
7

Description

I have zarr stores with each having multiple images. Part of this data got corrupted at some point. While each image store did have a .zattrs file, some of these were empty.

Currently in io_raster.py the error message that occurs when this happens is as follows:

f"len(nodes) = {len(nodes)}, expected 1. Unable to read the NGFF file. Please report this "
            f"bug and attach a minimal data example."

While already informative, it does not tell me for how many images this is the case or for which image this error occurs and whether other images are properly being read. Right now I did trouble shooting by just using native functions of ome_zarr

Easiest way to already give some more information is to use the store parameter as pathlib.Path in _read_multiscale:

line 56-57

f"len(nodes) of {store.stem} = {len(nodes)}, expected 1. Unable to read the NGFF file. Please report this "
            f"bug and attach a minimal data example."

Since images are lazily loaded would it be an idea to not throw an error at this stage, but rather create a dictionary which is used at the end of reading into spatialdata to throw the error with indication of which images had this particular problem?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in io_raster.py, especially _read_multiscale and the error around lines 56-57, and review how store is passed and how images are read into spatialdata. Compare the current message with the proposed store.stem detail and consider the deferred error-reporting idea. Done means errors identify the affected image or images while preserving the existing NGFF reading behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.