Skip to content

Commit 41b3c66

Browse files
John-Pshaneahmed
andauthored
✨ Return True for is_ngff With Warning Above Max NGFF Version (#577)
This PR Changes `is_ngff` to return True when above the max supported version with a warning logged. Co-authored-by: Shan Raza <[email protected]>
1 parent 8b18a44 commit 41b3c66

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

tests/test_wsireader.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,7 +2118,7 @@ def test_ngff_omero_below_min_version(tmp_path):
21182118
wsireader.WSIReader.open(sample_copy)
21192119

21202120

2121-
def test_ngff_omero_above_max_version(tmp_path):
2121+
def test_ngff_omero_above_max_version(tmp_path, caplog):
21222122
"""Test for FileNotSupported when omero version is above maximum."""
21232123
sample = _fetch_remote_sample("ngff-1")
21242124
# Create a copy of the sample
@@ -2130,8 +2130,10 @@ def test_ngff_omero_above_max_version(tmp_path):
21302130
zattrs["omero"]["version"] = "10.0"
21312131
with open(sample_copy / ".zattrs", "w") as fh:
21322132
json.dump(zattrs, fh, indent=2)
2133-
with pytest.raises(FileNotSupported):
2133+
# Check that the warning is logged
2134+
with caplog.at_level(logging.WARNING):
21342135
wsireader.WSIReader.open(sample_copy)
2136+
assert "maximum supported version" in caplog.text
21352137

21362138

21372139
def test_ngff_multiscales_below_min_version(tmp_path):
@@ -2150,7 +2152,7 @@ def test_ngff_multiscales_below_min_version(tmp_path):
21502152
wsireader.WSIReader.open(sample_copy)
21512153

21522154

2153-
def test_ngff_multiscales_above_max_version(tmp_path):
2155+
def test_ngff_multiscales_above_max_version(tmp_path, caplog):
21542156
"""Test for FileNotSupported when multiscales version is above maximum."""
21552157
sample = _fetch_remote_sample("ngff-1")
21562158
# Create a copy of the sample
@@ -2162,8 +2164,10 @@ def test_ngff_multiscales_above_max_version(tmp_path):
21622164
zattrs["multiscales"][0]["version"] = "10.0"
21632165
with open(sample_copy / ".zattrs", "w") as fh:
21642166
json.dump(zattrs, fh, indent=2)
2165-
with pytest.raises(FileNotSupported):
2167+
# Check that the warning is logged
2168+
with caplog.at_level(logging.WARNING):
21662169
wsireader.WSIReader.open(sample_copy)
2170+
assert "maximum supported version" in caplog.text
21672171

21682172

21692173
def test_ngff_non_numeric_version(tmp_path, monkeypatch):

tiatoolbox/wsicore/wsireader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def is_ngff(
165165
max_version,
166166
multiscales_versions,
167167
)
168-
return False
168+
return True
169169

170170
if len(multiscales_versions) > 1:
171171
logger.warning(
@@ -189,7 +189,7 @@ def is_ngff(
189189
max_version,
190190
multiscales_versions,
191191
)
192-
return False
192+
return True
193193

194194
return is_zarr(path)
195195

0 commit comments

Comments
 (0)