From 599ce4e65be43bc0991d2804dd27fdd4f8cc0cfd Mon Sep 17 00:00:00 2001 From: Jakub Kaczmarzyk Date: Mon, 9 Jan 2023 13:01:15 -0500 Subject: [PATCH 1/3] add geojson to dev + test that converted geojson is valid --- setup.cfg | 1 + tests/test_all.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 1bf0836..bcde65f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,7 @@ install_requires = dev = black flake8 + geojson imagecodecs # for tifffile mypy pytest diff --git a/tests/test_all.py b/tests/test_all.py index a6d26fd..4f276e9 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -7,6 +7,7 @@ from typing import List from click.testing import CliRunner +import geojson as geojsoblib import h5py import numpy as np import pandas as pd @@ -323,7 +324,8 @@ def test_cli_run_regression( result = runner.invoke(cli, ["togeojson", str(results_dir), str(geojson_dir)]) assert result.exit_code == 0 with open(geojson_dir / "purple.json") as f: - d = json.load(f) + d: geojsoblib.GeoJSON = geojsoblib.load(f) + assert d.is_valid, "geojson not valid!" assert len(d["features"]) == expected_num_patches for geojson_row in d["features"]: From 78d59f1b5409ca0fe1d6bfc1f8ecf2fa0af3b627 Mon Sep 17 00:00:00 2001 From: Jakub Kaczmarzyk Date: Mon, 9 Jan 2023 13:10:20 -0500 Subject: [PATCH 2/3] update copyright year to 2023 --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 0da0bef..cfe2276 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -7,7 +7,7 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information project = "wsinfer" -copyright = "2022, Jakub Kaczmarzyk" +copyright = "2023, Jakub Kaczmarzyk" author = "Jakub Kaczmarzyk" # -- General configuration --------------------------------------------------- From 45feee1443c33761dee663c7a98a8476ae2d0463 Mon Sep 17 00:00:00 2001 From: Jakub Kaczmarzyk Date: Mon, 9 Jan 2023 13:15:19 -0500 Subject: [PATCH 3/3] fix type errors --- tests/test_all.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/test_all.py b/tests/test_all.py index 4f276e9..ef5637f 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -98,13 +98,13 @@ def test_cli_list(tmp_path: Path): ) assert ret.returncode == 0 output = ret.stdout.decode() - assert configs[0]["name"] in output - assert configs[0]["architecture"] in output - assert configs[1]["name"] in output - assert configs[1]["architecture"] in output + assert configs[0]["name"] in output # type: ignore + assert configs[0]["architecture"] in output # type: ignore + assert configs[1]["name"] in output # type: ignore + assert configs[1]["architecture"] in output # type: ignore # Negative control. ret = subprocess.run([sys.executable, "-m", "wsinfer", "list"], capture_output=True) - assert configs[0]["name"] not in ret.stdout.decode() + assert configs[0]["name"] not in ret.stdout.decode() # type: ignore del config_root_single, output, ret, config # Test of WSINFER_PATH registration... check that the models appear in list. @@ -124,12 +124,12 @@ def test_cli_list(tmp_path: Path): ) assert ret.returncode == 0 output = ret.stdout.decode() - assert configs[0]["name"] in output - assert configs[0]["architecture"] in output - assert configs[1]["name"] in output - assert configs[1]["architecture"] in output + assert configs[0]["name"] in output # type: ignore + assert configs[0]["architecture"] in output # type: ignore + assert configs[1]["name"] in output # type: ignore + assert configs[1]["architecture"] in output # type: ignore ret = subprocess.run([sys.executable, "-m", "wsinfer", "list"], capture_output=True) - assert configs[0]["name"] not in ret.stdout.decode() + assert configs[0]["name"] not in ret.stdout.decode() # type: ignore def test_cli_run_args(tmp_path: Path): @@ -143,9 +143,9 @@ def test_cli_run_args(tmp_path: Path): args = [ "run", "--wsi-dir", - wsi_dir, + str(wsi_dir), "--results-dir", - tmp_path / "results", + str(tmp_path / "results"), ] # No model, weights, or config. result = runner.invoke(cli, args) @@ -257,7 +257,7 @@ def test_cli_run_args(tmp_path: Path): def test_cli_run_regression( model: str, weights: str, - class_names: List[float], + class_names: List[str], expected_probs: List[float], expected_patch_size: int, expected_num_patches: int, @@ -274,13 +274,13 @@ def test_cli_run_regression( [ "run", "--wsi-dir", - tiff_image.parent, + str(tiff_image.parent), "--model", model, "--weights", weights, "--results-dir", - results_dir, + str(results_dir), ], ) assert result.exit_code == 0 @@ -381,11 +381,11 @@ def test_cli_run_from_config(tiff_image: Path, tmp_path: Path): [ "run", "--wsi-dir", - tiff_image.parent, + str(tiff_image.parent), "--config", - config, + str(config), "--results-dir", - results_dir, + str(results_dir), ], ) assert result.exit_code == 0