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

support cache file system #545

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions aicsimageio/readers/nd2_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

from typing import TYPE_CHECKING, Any, Dict, Tuple

from fsspec.implementations.local import LocalFileSystem

from .reader import Reader
from .. import constants, exceptions, types
from ..utils import io_utils
from .reader import Reader

if TYPE_CHECKING:
import xarray as xr
from fsspec.spec import AbstractFileSystem
from ome_types import OME


try:
import nd2
except ImportError:
Expand Down Expand Up @@ -52,12 +49,6 @@ def __init__(self, image: types.PathLike, fs_kwargs: Dict[str, Any] = {}):
enforce_exists=True,
fs_kwargs=fs_kwargs,
)
# Catch non-local file system
if not isinstance(self._fs, LocalFileSystem):
raise ValueError(
f"Cannot read ND2 from non-local file system. "
f"Received URI: {self._path}, which points to {type(self._fs)}."
)

if not self._is_supported_image(self._fs, self._path):
raise exceptions.UnsupportedFileFormatError(
Expand Down
11 changes: 10 additions & 1 deletion aicsimageio/tests/readers/extra_readers/test_nd2_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from aicsimageio import AICSImage, dimensions, exceptions
from aicsimageio.readers.nd2_reader import ND2Reader
from aicsimageio.tests.image_container_test_utils import run_image_file_checks

from ...conftest import LOCAL, get_resource_full_path, host

nd2 = pytest.importorskip("nd2")
Expand Down Expand Up @@ -270,3 +269,13 @@ def test_frame_metadata() -> None:
assert isinstance(
rdr.xarray_data.attrs["unprocessed"]["frame"], nd2.structures.FrameMetadata
)


def test_non_local_read() -> None:
filename = "ND2_dims_rgb_t3p2c2z3x64y64.nd2"
uri = get_resource_full_path(filename, LOCAL)
rdr = ND2Reader("simplecache::" + str(uri))
rdr.set_scene(0)
assert isinstance(
rdr.xarray_data.attrs["unprocessed"]["frame"], nd2.structures.FrameMetadata
)
Loading