Skip to content

custom implementation of is_supported_image classmethod #20

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

Merged
merged 2 commits into from
Apr 30, 2024
Merged
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
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