Skip to content
Merged
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
16 changes: 7 additions & 9 deletions .github/workflows/run_pytests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.13"]
python-version: ["3.14"]
include:
# we'll test the python support on ubuntu
- os: ubuntu-latest
python-version: "3.13"
- os: ubuntu-latest
python-version: "3.12"
- os: ubuntu-latest
python-version: "3.11"
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.9"
steps:
- name: Checkout TiffSlide
uses: actions/checkout@v3
Expand All @@ -55,14 +53,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev]
- name: Run mypy
run: |
mypy --install-types --non-interactive --python-version=3.9 tiffslide
mypy --install-types --non-interactive --python-version=3.11 tiffslide

# DEPLOY TIFFSLIDE TO TEST.PYPI ON SUCCESS
testdeploy:
Expand All @@ -77,7 +75,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -114,7 +112,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
8 changes: 5 additions & 3 deletions docs/generate_benchmark_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ def run_pytest_benchmarks(force: bool) -> None:

df = pd.DataFrame.from_records(records)
for test_name, ptdf in df.groupby("test_name"):
ft_ax_order = [
ft_ax_order_all = [
"svs",
"svs_jp2k",
"generic",
"hamamatsu",
"leica",
"ventana",
]
assert set(ptdf["file_type"].unique()) == set(ft_ax_order)
fig, axes = plt.subplots(1, len(ft_ax_order), figsize=(10, 4))
available = set(ptdf["file_type"].unique())
ft_ax_order = [ft for ft in ft_ax_order_all if ft in available]
fig, axes = plt.subplots(1, len(ft_ax_order), figsize=(10, 4), squeeze=False)
axes = axes[0] # unwrap row dimension
fig.suptitle(test_name, x=0.1, y=0.99)
ft_ax_map = {ft: ax for ft, ax in zip(ft_ax_order, axes)}

Expand Down
14 changes: 6 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ classifiers = [
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
Expand All @@ -32,13 +30,13 @@ classifiers = [
"Operating System :: Unix",
"Operating System :: MacOS",
]
requires-python = ">=3.9"
requires-python = ">=3.11"
dependencies = [
"imagecodecs",
"fsspec>=2023.3.0",
"fsspec>=2024.10.0",
"pillow>=9.1.0",
"tifffile>=2023.7.4,<2025.5.21",
"zarr>=2.16.0,<3.0",
"tifffile>=2025.5.21",
"zarr>=3.0,<4.0",
"typing_extensions>=4.0",
]
dynamic = ["version"]
Expand Down Expand Up @@ -90,7 +88,7 @@ markers = [

[tool.isort]
profile = "black"
py_version = "39"
py_version = "311"
force_single_line = true
extend_skip = ["setup.py", "docs/source/conf.py"]

Expand All @@ -107,7 +105,7 @@ exclude_lines = [
]

[tool.mypy]
python_version = "3.9"
python_version = "3.11"
check_untyped_defs = true
disallow_any_generics = true
disallow_incomplete_defs = true
Expand Down
9 changes: 8 additions & 1 deletion tiffslide/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,14 @@ def size(self) -> int:
return self._array.size

def aszarr(self) -> zarr.storage.MemoryStore:
return zarr.creation.array(self._array).store
store = zarr.storage.MemoryStore()
zarr.create_array(
store=store,
data=self._array,
chunks=self._array.shape,
zarr_format=2,
)
return store

def asarray(self) -> NDArray[np.uint8]:
return self._array
8 changes: 7 additions & 1 deletion tiffslide/_kerchunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
import json
import os
import sys
import threading
from collections import ChainMap
from io import StringIO
from typing import TYPE_CHECKING
from typing import Any
from typing import TypedDict

import fsspec
from fsspec.asyn import get_loop
from fsspec.asyn import sync as _fsspec_sync
from imagecodecs.numcodecs import register_codecs

from tiffslide.tiffslide import TiffSlide
Expand Down Expand Up @@ -137,9 +140,10 @@ def from_kerchunk(
fs: ReferenceFileSystem = fsspec.filesystem(
"reference",
fo=kc,
asynchronous=True,
**storage_options,
)
zattrs = json.loads(fs.cat_file(".zattrs"))
zattrs = json.loads(_fsspec_sync(get_loop(), fs._cat_file, ".zattrs"))

if "tiffslide.spec_version" not in zattrs or "tiffslide.properties" not in zattrs:
raise ValueError("")
Expand All @@ -155,6 +159,8 @@ def from_kerchunk(
inst = object.__new__(TiffSlide)
inst.__dict__["properties"] = properties
inst._tifffile = fs # fixme: ...
inst._zarr_local = threading.local()
inst._zarr_lock = threading.Lock()
return inst


Expand Down
Loading