Skip to content

Commit

Permalink
support cache file system
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-gould committed Nov 14, 2023
1 parent 797bcab commit ba3d869
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
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
)

0 comments on commit ba3d869

Please sign in to comment.