Skip to content

Commit f43e7d5

Browse files
committed
Adding guards for tests and dependencies versions
1 parent 74c19f9 commit f43e7d5

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

tests/integration/converters/test_ome_zarr.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import sys
23

34
import numpy as np
45
import PIL.Image
@@ -14,6 +15,15 @@
1415
from tiledb.bioimg.openslide import TileDBOpenSlide
1516
from tiledb.filter import WebpFilter
1617

18+
try:
19+
from ome_zarr.format import FormatV05
20+
21+
HAS_FORMAT_V05 = True
22+
except ImportError:
23+
FormatV05 = None
24+
25+
26+
REQUIRED_PYTHON_v3 = (3, 12)
1727
schemas = (get_schema(2220, 2967), get_schema(387, 463), get_schema(1280, 431))
1828

1929

@@ -165,6 +175,12 @@ def test_ome_zarr_converter_rountrip_v2(
165175
np.testing.assert_array_equal(input_array, output_array)
166176

167177

178+
# Condition to check if the current Python version is less than the required version
179+
# The test is skipped if the condition is True
180+
@pytest.mark.skipif(
181+
sys.version_info < REQUIRED_PYTHON_v3,
182+
reason=f"This test requires Python version {REQUIRED_PYTHON_v3[0]}.{REQUIRED_PYTHON_v3[1]} or higher.",
183+
)
168184
@pytest.mark.parametrize("series_idx", [0, 1, 2])
169185
@pytest.mark.parametrize("preserve_axes", [False, True])
170186
@pytest.mark.parametrize("chunked,max_workers", [(False, 0), (True, 0), (True, 4)])

tiledb/bioimg/converters/ome_zarr.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@
4343
)
4444
raise err
4545

46+
try:
47+
from ome_zarr.format import FormatV05
48+
except ImportError:
49+
warnings.warn(
50+
"FormatV05 not available. Zarr v3 format requires ome-zarr>=0.9.0. "
51+
"Falling back to FormatV04 (Zarr v2). "
52+
"To use Zarr v3, upgrade: pip install --upgrade ome-zarr",
53+
UserWarning,
54+
stacklevel=2,
55+
)
56+
4657
from tiledb import Config, Ctx
4758
from tiledb.filter import WebpFilter
4859
from tiledb.highlevel import _get_ctx

0 commit comments

Comments
 (0)