Skip to content

Commit f8a0473

Browse files
authored
Remove guards now part of npe2 from napari_get_reader (#51)
# Description These guards are legacy code from the era of `napari-plugin-engine`. npe2 now provides these guards via `napari.yaml` 1. Multi-path vs single-path are determined by manifest 2. compatible paths are determined by manifest, and later we want to raise helpful errors for missing bioio plugins. This removes both these guards. Instead, `napari_get_reader` should provide explicit guards for known incompatibilities (see #50 )
1 parent 6d4439a commit f8a0473

File tree

2 files changed

+5
-54
lines changed

2 files changed

+5
-54
lines changed

src/ndevio/_napari_reader.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ def napari_get_reader(
1919
open_first_scene_only: bool | None = None,
2020
open_all_scenes: bool | None = None,
2121
) -> ReaderFunction | None:
22-
"""
23-
Get the appropriate reader function for a single given path.
24-
25-
Uses a quick extension check to determine if any bioio plugin might
26-
support this file. If so, returns a reader function that will use
27-
bioio's priority system to try each installed reader.
22+
"""Get the appropriate reader function for a single given path.
2823
2924
Parameters
3025
----------
@@ -41,24 +36,9 @@ def napari_get_reader(
4136
4237
Returns
4338
-------
44-
ReaderFunction or None
45-
The reader function for the given path, or None if extension
46-
is not recognized by any bioio plugin.
47-
39+
ReaderFunction
40+
The reader function for the given path
4841
"""
49-
from .bioio_plugins._utils import suggest_plugins_for_path
50-
51-
if isinstance(path, list):
52-
logger.info('Bioio: Expected a single path, got a list of paths.')
53-
return None
54-
55-
# Quick extension check - if no plugins recognize this extension, return None
56-
# This allows other napari readers to try the file
57-
# TODO: This is probably legacy cruft before starting to autopopulate the filename_patterns in napari.yaml
58-
suggested = suggest_plugins_for_path(path)
59-
if not suggested:
60-
logger.debug('ndevio: No bioio plugins for extension: %s', path)
61-
return None
6242

6343
settings = get_settings()
6444

@@ -74,8 +54,8 @@ def napari_get_reader(
7454
else settings.ndevio_reader.scene_handling == 'View All Scenes' # type: ignore
7555
) or False
7656

77-
# Extension is recognized - return a reader function
78-
# The actual reading happens in napari_reader_function
57+
# Return reader function; actual format validation happens in
58+
# napari_reader_function via nImage initialization.
7959
return partial(
8060
napari_reader_function,
8161
open_first_scene_only=open_first_scene_only,

tests/test_napari_reader.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -153,35 +153,6 @@ def test_for_multiscene_widget(
153153
assert data.shape == expected_shape
154154

155155

156-
def test_napari_get_reader_multi_path(resources_dir: Path) -> None:
157-
# Get reader
158-
reader = napari_get_reader(
159-
[str(resources_dir / RGB_TIFF), str(resources_dir / MULTISCENE_CZI)],
160-
)
161-
162-
# Check callable
163-
assert reader is None
164-
165-
166-
def test_napari_get_reader_ome_override(resources_dir: Path) -> None:
167-
reader = napari_get_reader(
168-
str(resources_dir / OME_TIFF),
169-
)
170-
171-
assert callable(reader)
172-
173-
174-
def test_napari_get_reader_unsupported(resources_dir: Path):
175-
"""Test that unsupported file extension returns None per napari reader spec."""
176-
reader = napari_get_reader(
177-
str(resources_dir / 'measure_props_Labels.abcdefg'),
178-
)
179-
180-
# Should return None for unsupported formats (per napari spec)
181-
# Unknown extensions are quickly rejected via suggest_plugins_for_path()
182-
assert reader is None
183-
184-
185156
def test_napari_get_reader_supported_formats_work(resources_dir: Path):
186157
"""Test that supported formats return valid readers."""
187158
# PNG should work (bioio-imageio is core)

0 commit comments

Comments
 (0)