Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't handle exception in Multiscales init() #266

Merged
merged 3 commits into from
Apr 4, 2023

Conversation

will-moore
Copy link
Member

See #258.

This removes the exception handling that was obscuring useful errors there.

E.g. edit a sample zarr to an invalid version, e.g. "version": 0.5 then try to open in napari:

$ napari --plugin napari-ome-zarr /path/to/image.zarr

Traceback (most recent call last):
  File "/Users/wmoore/opt/anaconda3/envs/SSBD/bin/napari", line 8, in <module>
    sys.exit(main())
  File "/Users/wmoore/opt/anaconda3/envs/ssbd/lib/python3.9/site-packages/napari/__main__.py", line 570, in main
    _run()
  File "/Users/wmoore/opt/anaconda3/envs/ssbd/lib/python3.9/site-packages/napari/__main__.py", line 344, in _run
    viewer._window._qt_viewer._qt_open(
  File "/Users/wmoore/opt/anaconda3/envs/ssbd/lib/python3.9/site-packages/napari/_qt/qt_viewer.py", line 867, in _qt_open
    self.viewer.open(
  File "/Users/wmoore/opt/anaconda3/envs/ssbd/lib/python3.9/site-packages/napari/components/viewer_model.py", line 1076, in open
    self._add_layers_with_plugins(
  File "/Users/wmoore/opt/anaconda3/envs/ssbd/lib/python3.9/site-packages/napari/components/viewer_model.py", line 1276, in _add_layers_with_plugins
    layer_data, hookimpl = read_data_with_plugins(
  File "/Users/wmoore/opt/anaconda3/envs/ssbd/lib/python3.9/site-packages/napari/plugins/io.py", line 77, in read_data_with_plugins
    res = _npe2.read(paths, plugin, stack=stack)
  File "/Users/wmoore/opt/anaconda3/envs/ssbd/lib/python3.9/site-packages/napari/plugins/_npe2.py", line 61, in read
    raise e from e
  File "/Users/wmoore/opt/anaconda3/envs/ssbd/lib/python3.9/site-packages/napari/plugins/_npe2.py", line 55, in read
    layer_data, reader = io_utils.read_get_reader(
  File "/Users/wmoore/opt/anaconda3/envs/ssbd/lib/python3.9/site-packages/npe2/io_utils.py", line 66, in read_get_reader
    return _read(
  File "/Users/wmoore/opt/anaconda3/envs/ssbd/lib/python3.9/site-packages/npe2/io_utils.py", line 163, in _read
    ld = read_func(paths, stack=stack)
  File "/Users/wmoore/opt/anaconda3/envs/ssbd/lib/python3.9/site-packages/npe2/manifest/contributions/_readers.py", line 60, in npe1_compat
    return callable_(path)  # type: ignore
  File "/Users/wmoore/Desktop/ZARR/napari-ome-zarr/napari_ome_zarr/_reader.py", line 108, in f
    for node in nodes:
  File "/Users/wmoore/Desktop/ZARR/ome-zarr-py/ome_zarr/reader.py", line 625, in __call__
    node = Node(self.zarr, self)
  File "/Users/wmoore/Desktop/ZARR/ome-zarr-py/ome_zarr/reader.py", line 53, in __init__
    self.specs.append(Multiscales(self))
  File "/Users/wmoore/Desktop/ZARR/ome-zarr-py/ome_zarr/reader.py", line 286, in __init__
    fmt = format_from_version(version)
  File "/Users/wmoore/Desktop/ZARR/ome-zarr-py/ome_zarr/format.py", line 22, in format_from_version
    raise ValueError(f"Version {version} not recognized")
ValueError: Version 0.5 not recognized

@codecov
Copy link

codecov bot commented Mar 20, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.24 🎉

Comparison is base (9540832) 84.54% compared to head (7b56cb7) 84.78%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #266      +/-   ##
==========================================
+ Coverage   84.54%   84.78%   +0.24%     
==========================================
  Files          13       13              
  Lines        1475     1472       -3     
==========================================
+ Hits         1247     1248       +1     
+ Misses        228      224       -4     
Impacted Files Coverage Δ
ome_zarr/data.py 87.12% <100.00%> (+0.12%) ⬆️
ome_zarr/reader.py 86.70% <100.00%> (+0.64%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@will-moore
Copy link
Member Author

@joshmoore This look OK to you? Hope to get this in a release soon if no objections?

Copy link
Member

@joshmoore joshmoore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 as well as for the quick release.

I assume there's code hanging around that's checking for the missing node data and metadata after the exception which may need to now handle the exception, but those should appear fairly quickly.

With the addition of the schemas, the better longer-term strategy would likely be to use the schema and raise a validation exception

@joshmoore joshmoore merged commit 198a959 into ome:master Apr 4, 2023
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.

None yet

2 participants