Skip to content

Commit

Permalink
Merge pull request #20 from bioio-devs/fix/http-ome-zarr-loading
Browse files Browse the repository at this point in the history
custom implementation of is_supported_image classmethod
  • Loading branch information
toloudis authored Apr 30, 2024
2 parents 964a301 + bbf5942 commit 6e29c3d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bioio_ome_zarr/reader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import warnings
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple

import xarray as xr
Expand Down Expand Up @@ -80,6 +81,25 @@ def _is_supported_image(fs: AbstractFileSystem, path: str, **kwargs: Any) -> boo
except AttributeError:
return False

@classmethod
def is_supported_image(
cls,
image: types.ImageLike,
fs_kwargs: Dict[str, Any] = {},
**kwargs: Any,
) -> bool:
if isinstance(image, (str, Path)):
try:
ZarrReader(parse_url(image, mode="r"))
return True

except AttributeError:
return False
else:
return reader.Reader.is_supported_image(
cls, image, fs_kwargs=fs_kwargs, **kwargs
)

@property
def scenes(self) -> Tuple[str, ...]:
if self._scenes is None:
Expand Down

0 comments on commit 6e29c3d

Please sign in to comment.