Skip to content

Commit

Permalink
🔖 Release 0.6.1 (#43)
Browse files Browse the repository at this point in the history
* 🐛 Fix Writing MPP To NGFF v0.4 Zarr (#37)

* 🐛 Change CoordinateTransform Order To YXC (#41)

* 🐛 Fix Reading TIFF Resolution Tag

* 🐛 Minor Bug Fixes (#40)

* 🐛 Ensure cv2 Arg Is an int Tuple

* ✨ Add TIFF Writer For CLI Based On Ext

* 🐛 Add Missing **kwargs

* 🚸 Change TIFFWriter OME Default To False

* ✏️ Typo Fix transcribed -> transcoded

* ♻️ Move CLI Tests To Seperate Module

* 🐛 Fix Typo in Class For Transcoding From DICOM

* ✅ Add CLI Tests

* 🔧 Add release Branch To Workflows

* 🔖 Bump version: 0.5.1 → 0.6.1

* 🔧 Set Tag To False In bump2version Config

* ♻️ Rename Module To Avoid Shadowing

* 📝 Update History

* 📝 Reverse History Ordering
  • Loading branch information
John-P authored Oct 21, 2022
1 parent bb067e5 commit ccc6f7a
Show file tree
Hide file tree
Showing 13 changed files with 310 additions and 150 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ name: Python application

on:
push:
branches: [ dev, main ]
branches: [ dev, main, release ]
tags: v*
pull_request:
branches: [ dev, main ]
branches: [ dev, main, release ]

permissions:
contents: read
Expand Down
55 changes: 53 additions & 2 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,60 @@
# History

## 0.1.0 (2022-02-22)
## 0.6.1 (2022-10-21)

- First release on PyPI.
- Select Writer class based on file extension from CLI.
- Bug fixes:
- Fix writing MPP to NGFF v0.4.
- Change coordinate transformation ordering.
- Fix reading TIFF resolution tag. Previously only the numerator of
the resolution fraction was being read.
- Other minor bug fixes.

## 0.6.0 (2022-10-03)

- Add ability to write resolution metadata to JP2. Thanks to
@quintusdias for helping get this implemented in glymur.
- Remove QOI codec code as this is not included in imagecodes. Thanks to
Christoph Gohlke for adding this.
- Add a "How do I?" documentation page.

## 0.5.1 (2022-06-27)

- Bug fixes:
- Fix parsing of OpenSlide MPP to float.

## 0.5.0 (2022-06-25)

- Add ability to transcode/repackage to a TIFF file (from DICOM or SVS).
- Refactor `ZarrReaderWriter` to seperate `ZarrWriter` and `ZarrReader`.
- Bug fixes:
- Fix thumbnaiul generation for zarr.
- Fix NGFF metadata `CoordinateTransformation` field default factor.

## 0.4.0 (2022-06-20)

- Add ability to write JPEG compressed SVS files.
- Add support for thumbnail generation and a CLI command.
- Swap from strings to enums for codecs and color spaces.

## 0.3.0 (2022-05-13)

- Remove unused CLI debug option.
- Add generation of OME-NGFF metadata (JSON .zattrs file).
- Add timeout when copying tiles to prevent indefinite hanging.
- Improve joining/termination of child processes at shutdown.
- Use the TIFF resolution tag if present.
- Add `get_tile` method to all `Reader` classes.
- Update supported Python versions to 3.8, 3.9, 3.10.
- Bug fixes:
- Fix and issue with concatenation of pyramid downsamples.
- Add a custom Queue class for multiprocessing on macOS.
- Fix handling of `pyramid_downsamples` argument when `None`.

## 0.2.0 (2022-03-22)

- Add Support To Read DICOM WSI and transform to zarr.

## 0.1.0 (2022-02-22)

- First release on PyPI.
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[bumpversion]
current_version = 0.6.0
current_version = 0.6.1
message = :bookmark: Bump version: {current_version} → {new_version}
tag_message = :bookmark: Bump version: {current_version} → {new_version}
commit = True
tag = True
tag = False

[bumpversion:file:setup.py]
search = version="{current_version}"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@
tests_require=test_requirements,
extras_require=extra_requirements,
url="https://github.com/john-p/wsic",
version="0.6.0",
version="0.6.1",
zip_safe=False,
)
182 changes: 182 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import sys
import warnings
from pathlib import Path

import pytest
from click.testing import CliRunner

from wsic import cli


def test_convert_timeout(samples_path, tmp_path):
"""Check that CLI convert raises IOError when reading times out."""
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path) as td:
in_path = str(samples_path / "XYC.jp2")
out_path = str(Path(td) / "XYC.tiff")
warnings.simplefilter("ignore")
with pytest.raises(IOError, match="timed out"):
runner.invoke(
cli.convert,
["-i", in_path, "-o", out_path, "--timeout", "0"],
catch_exceptions=False,
)


def test_thumbnail(samples_path, tmp_path):
"""Check that CLI thumbnail works."""
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path) as td:
in_path = samples_path / "XYC.jp2"
out_path = Path(td) / "XYC.jpeg"
runner.invoke(
cli.thumbnail,
["-i", str(in_path), "-o", str(out_path), "-s", "512", "512"],
catch_exceptions=False,
)
assert out_path.exists()
assert out_path.is_file()
assert out_path.stat().st_size > 0


def test_thumbnail_downsample(samples_path, tmp_path):
"""Check that CLI thumbnail works with downsample option."""
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path) as td:
in_path = samples_path / "XYC.jp2"
out_path = Path(td) / "XYC.jpeg"
result = runner.invoke(
cli.thumbnail,
["-i", str(in_path), "-o", str(out_path), "-d", "16"],
catch_exceptions=False,
)
assert result.exit_code == 0
assert out_path.exists()
assert out_path.is_file()
assert out_path.stat().st_size > 0


def test_thumbnail_no_cv2(samples_path, tmp_path, monkeypatch):
"""Check that CLI thumbnail works without OpenCV (cv2)."""
monkeypatch.setitem(sys.modules, "cv2", None)
with pytest.raises(ImportError):
import cv2 # noqa # skipcq
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path) as td:
in_path = samples_path / "XYC.jp2"
out_path = Path(td) / "XYC.jpeg"
runner.invoke(
cli.thumbnail,
["-i", str(in_path), "-o", str(out_path), "-s", "512", "512"],
catch_exceptions=False,
)
assert out_path.exists()
assert out_path.is_file()
assert out_path.stat().st_size > 0


def test_help():
"""Test the help output."""
runner = CliRunner()
help_result = runner.invoke(cli.main, ["--help"])
assert help_result.exit_code == 0
assert "Console script for wsic." in help_result.output


def test_transcode_svs_to_zarr(samples_path, tmp_path):
"""Test the CLI for transcoding SVS to zarr."""
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path) as td:
in_path = str(samples_path / "CMU-1-Small-Region.svs")
out_path = str(Path(td) / "CMU-1-Small-Region.zarr")
result = runner.invoke(
cli.transcode,
["-i", in_path, "-o", out_path],
catch_exceptions=False,
)
assert result.exit_code == 0


def test_transcode_svs_to_tiff(samples_path, tmp_path):
"""Test the CLI for transcoding SVS to (tiled) TIFF."""
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path) as td:
in_path = str(samples_path / "CMU-1-Small-Region.svs")
out_path = str(Path(td) / "CMU-1-Small-Region.tiff")
result = runner.invoke(
cli.transcode,
["-i", in_path, "-o", out_path],
catch_exceptions=False,
)
assert result.exit_code == 0


def test_transcode_dicom_to_tiff(samples_path, tmp_path):
"""Test the CLI for transcoding DICOM to (tiled) TIFF."""
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path) as td:
in_path = str(samples_path / "CMU-1-Small-Region")
out_path = str(Path(td) / "CMU-1-Small-Region.tiff")
result = runner.invoke(
cli.transcode,
["-i", in_path, "-o", out_path],
catch_exceptions=False,
)
assert result.exit_code == 0


def test_convert_jp2_to_tiff(samples_path, tmp_path):
"""Test the CLI for converting JP2 to tiled TIFF."""
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path) as td:
in_path = str(samples_path / "XYC.jp2")
out_path = str(Path(td) / "XYC.tiff")
result = runner.invoke(
cli.convert,
["-i", in_path, "-o", out_path],
catch_exceptions=False,
)
assert result.exit_code == 0


def test_convert_jp2_to_zarr(samples_path, tmp_path):
"""Test the CLI for converting JP2 to zarr."""
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path) as td:
in_path = str(samples_path / "XYC.jp2")
out_path = str(Path(td) / "XYC.zarr")
result = runner.invoke(
cli.convert,
["-i", in_path, "-o", out_path],
catch_exceptions=False,
)
assert result.exit_code == 0


def test_transcode_bad_input_file_ext(samples_path, tmp_path):
"""Test the CLI for transcoding with a bad input file extension."""
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path) as td:
# in_path must exists but not be a valid input
in_path = str(samples_path / "XYC.jp2")
out_path = str(Path(td) / "XYC.tiff")
result = runner.invoke(
cli.transcode,
["-i", in_path, "-o", out_path],
catch_exceptions=False,
)
assert result.exit_code == 2


def test_transcode_bad_output_file_ext(samples_path, tmp_path):
"""Check that CLI raises click.BadParameter when output file extension is bad."""
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path) as td:
in_path = samples_path / "XYC-half-mpp.tiff"
out_path = Path(td) / "XYC.foo"
result = runner.invoke(
cli.transcode,
["-i", str(in_path), "-o", str(out_path)],
catch_exceptions=False,
)
assert result.exit_code == 2
Loading

0 comments on commit ccc6f7a

Please sign in to comment.