Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsitsi committed Jun 20, 2024
1 parent e8385e2 commit 6f38b8b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
12 changes: 10 additions & 2 deletions tiledb/bioimg/converters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@

class ImageReader(ABC):
@abstractmethod
def __init__(self, input_path: str, logger: logging.Logger, **kwargs: Any):
def __init__(
self,
input_path: str,
*,
logger: Optional[logging.Logger],
config: Optional[tiledb.Config] = None,
ctx: Optional[tiledb.Ctx] = None,
**kwargs: Any,
):
"""Initialize this ImageReader"""

def __enter__(self) -> ImageReader:
Expand Down Expand Up @@ -359,7 +367,7 @@ def to_tiledb(
reader = source
elif cls._ImageReaderType is not None:
reader = cls._ImageReaderType(
source, logger, **reader_kwargs if reader_kwargs else {}
source, logger=logger, **reader_kwargs if reader_kwargs else {}
)
else:
raise NotImplementedError(f"{cls} does not support importing")
Expand Down
6 changes: 5 additions & 1 deletion tiledb/bioimg/converters/ome_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from tiledb import VFS, Config, Ctx
from tiledb.cc import WebpInputFormat
from tiledb.highlevel import _get_ctx

from .. import ATTR_NAME, EXPORT_TILE_SIZE, WHITE_RGBA
from ..helpers import get_decimal_from_rgba, get_logger_wrapper, get_rgba, iter_color
Expand All @@ -21,6 +22,7 @@ class OMETiffReader(ImageReader):
def __init__(
self,
input_path: str,
*,
logger: Optional[logging.Logger] = None,
config: Optional[Config] = None,
ctx: Optional[Ctx] = None,
Expand All @@ -37,7 +39,9 @@ def __init__(

# Use VFS for all paths local or remote for reading the input image
self._input_path = input_path
self._vfs = VFS(config=config, ctx=ctx)
self._ctx = _get_ctx(ctx, config)
self._cfg = self._ctx.config()
self._vfs = VFS(config=self._cfg, ctx=self._ctx)
self._vfs_fh = self._vfs.open(input_path, mode="rb")
self._tiff = tifffile.TiffFile(self._vfs_fh)
# XXX ignore all but the first series
Expand Down
1 change: 1 addition & 0 deletions tiledb/bioimg/converters/ome_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class OMEZarrReader(ImageReader):
def __init__(
self,
input_path: str,
*,
logger: Optional[logging.Logger] = None,
config: Optional[Config] = None,
ctx: Optional[Ctx] = None,
Expand Down
4 changes: 3 additions & 1 deletion tiledb/bioimg/converters/openslide.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class OpenSlideReader(ImageReader):
def __init__(
self,
input_path: str,
*,
logger: Optional[logging.Logger] = None,
config: Optional[Config] = None,
ctx: Optional[Ctx] = None,
Expand All @@ -40,11 +41,12 @@ def __init__(
self._ctx = _get_ctx(ctx, config)
self._cfg = self._ctx.config()
self._logger = get_logger_wrapper(False) if not logger else logger
resolved_path = input_path
if is_remote_protocol(input_path):
resolved_path = cache_filepath(
input_path, config, ctx, self._logger, scratch_space
)
else:
resolved_path = input_path
self._osd = osd.OpenSlide(resolved_path)

def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
Expand Down

0 comments on commit 6f38b8b

Please sign in to comment.