Skip to content

Commit

Permalink
✨ Return True for is_ngff With Warning Above Max NGFF Version (#577)
Browse files Browse the repository at this point in the history
This PR Changes `is_ngff` to return True when above the max supported version with a warning logged.

Co-authored-by: Shan Raza <13048456+shaneahmed@users.noreply.github.com>
  • Loading branch information
John-P and shaneahmed authored Mar 31, 2023
1 parent 8b18a44 commit 41b3c66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions tests/test_wsireader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ def test_ngff_omero_below_min_version(tmp_path):
wsireader.WSIReader.open(sample_copy)


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


def test_ngff_multiscales_below_min_version(tmp_path):
Expand All @@ -2150,7 +2152,7 @@ def test_ngff_multiscales_below_min_version(tmp_path):
wsireader.WSIReader.open(sample_copy)


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


def test_ngff_non_numeric_version(tmp_path, monkeypatch):
Expand Down
4 changes: 2 additions & 2 deletions tiatoolbox/wsicore/wsireader.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def is_ngff(
max_version,
multiscales_versions,
)
return False
return True

if len(multiscales_versions) > 1:
logger.warning(
Expand All @@ -189,7 +189,7 @@ def is_ngff(
max_version,
multiscales_versions,
)
return False
return True

return is_zarr(path)

Expand Down

0 comments on commit 41b3c66

Please sign in to comment.