Skip to content

Commit 6e1e585

Browse files
committed
Merge branch 'dev-define-engines-abc' into dev-define-semantic-segmentor
# Conflicts: # tests/test_utils.py
2 parents 82a9876 + f5a4c35 commit 6e1e585

25 files changed

+642
-553
lines changed

requirements/requirements.conda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ dependencies:
99
- openslide
1010
- pip>=20.0.2
1111
- pixman>=0.39.0
12-
- python>=3.9, <=3.12
12+
- python>=3.10, <=3.13
1313
- pip:
1414
- -r requirements.txt

requirements/requirements.dev.conda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ dependencies:
99
- openslide
1010
- pip>=20.0.2
1111
- pixman>=0.39.0
12-
- python>=3.9, <=3.12
12+
- python>=3.10, <=3.13
1313
- pip:
1414
- -r requirements_dev.txt

requirements/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ filelock>=3.9.0
1010
flask>=2.2.2
1111
flask-cors>=4.0.0
1212
glymur>=0.12.7
13+
huggingface_hub>=0.33.3
1314
imagecodecs>=2022.9.26
1415
joblib>=1.1.1
1516
jupyterlab>=3.5.2

requirements/requirements.win64.conda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ dependencies:
99
- openjpeg>=2.4.0
1010
- pip>=20.0.2
1111
- pixman>=0.39.0
12-
- python>=3.9, <=3.12
12+
- python>=3.10, <=3.13
1313
- pip:
1414
- -r requirements.txt

requirements/requirements.win64.dev.conda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ dependencies:
99
- openjpeg>=2.4.0
1010
- pip>=20.0.2
1111
- pixman>=0.39.0
12-
- python>=3.9, <=3.12
12+
- python>=3.10, <=3.13
1313
- pip:
1414
- -r requirements_dev.txt

tests/conftest.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,3 +659,39 @@ def timed(fn: Callable, *args: object) -> (Callable, float):
659659
end = time.time()
660660
compile_time = end - start
661661
return result, compile_time
662+
663+
664+
_tmp_paths: list[Path] = []
665+
666+
667+
@pytest.fixture
668+
def track_tmp_path(tmp_path: Path) -> Path:
669+
"""This fixture tracks `tmp_path` for clean up.
670+
671+
Fixture that wraps pytest's built-in `tmp_path` and tracks each temporary path
672+
for later cleanup at the module level.
673+
674+
Returns:
675+
Path: The temporary directory path for the current test function.
676+
677+
"""
678+
_tmp_paths.append(tmp_path)
679+
return tmp_path
680+
681+
682+
@pytest.fixture(scope="module", autouse=True)
683+
def module_teardown() -> None:
684+
"""This module tears down temporary data directories.
685+
686+
Module-scoped fixture that automatically runs after all tests in a module.
687+
It cleans up all temporary paths tracked during the module's execution.
688+
689+
Yields:
690+
None: Allows pytest to run tests before executing the teardown logic.
691+
692+
"""
693+
yield
694+
for path in _tmp_paths:
695+
if path.exists():
696+
shutil.rmtree(path)
697+
print(f"Cleaned up: {path}")

tests/models/test_arch_micronet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_value_error() -> None:
5454
toolbox_env.running_on_ci() or not ON_GPU,
5555
reason="Local test on machine with GPU.",
5656
)
57-
def test_micronet_output(remote_sample: Callable, tmp_path: Path) -> None:
57+
def test_micronet_output(remote_sample: Callable, track_tmp_path: Path) -> None:
5858
"""Test the output of MicroNet."""
5959
svs_1_small = Path(remote_sample("svs-1-small"))
6060
micronet_output = Path(remote_sample("micronet-output"))
@@ -74,7 +74,7 @@ def test_micronet_output(remote_sample: Callable, tmp_path: Path) -> None:
7474
imgs=[
7575
svs_1_small,
7676
],
77-
save_dir=tmp_path / "output",
77+
save_dir=track_tmp_path / "output",
7878
)
7979

8080
output = np.load(output[0][1] + ".raw.0.npy")

tests/models/test_dataset.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ def test_kather_nonexisting_dir() -> None:
9898
_ = KatherPatchDataset(save_dir_path="non-existing-path")
9999

100100

101-
def test_kather_dataset(tmp_path: Path) -> None:
101+
def test_kather_dataset(track_tmp_path: Path) -> None:
102102
"""Test for kather patch dataset."""
103-
save_dir_path = tmp_path
103+
save_dir_path = track_tmp_path
104104

105105
# save to temporary location
106106
# remove previously generated data
@@ -162,9 +162,9 @@ def test_patch_dataset_path_imgs(
162162
assert sampled_img_shape[2] == size[2]
163163

164164

165-
def test_patch_dataset_list_imgs(tmp_path: Path) -> None:
165+
def test_patch_dataset_list_imgs(track_tmp_path: Path) -> None:
166166
"""Test for patch dataset with a list of images as input."""
167-
save_dir_path = tmp_path
167+
save_dir_path = track_tmp_path
168168

169169
size = (5, 5, 3)
170170
img = RNG.integers(low=0, high=255, size=size)
@@ -229,10 +229,10 @@ def test_patch_datasetarray_imgs() -> None:
229229
assert sampled_img_shape[2] == size[2]
230230

231231

232-
def test_patch_dataset_crash(tmp_path: Path) -> None:
232+
def test_patch_dataset_crash(track_tmp_path: Path) -> None:
233233
"""Test to make sure patch dataset crashes with incorrect input."""
234234
# all below examples should fail when input to PatchDataset
235-
save_dir_path = tmp_path
235+
save_dir_path = track_tmp_path
236236

237237
# not supported input type
238238
imgs = {"a": RNG.integers(0, 255, (4, 4, 4))}
@@ -341,7 +341,7 @@ def test_patch_dataset_crash(tmp_path: Path) -> None:
341341

342342
def test_wsi_patch_dataset( # noqa: PLR0915
343343
sample_wsi_dict: dict,
344-
tmp_path: Path,
344+
track_tmp_path: Path,
345345
) -> None:
346346
"""A test for creation and bare output."""
347347
# convert to pathlib Path to prevent wsireader complaint
@@ -488,7 +488,7 @@ def __getitem__(self: Proto, idx: int) -> object:
488488
)
489489
negative_mask = imread(mini_wsi_msk)
490490
negative_mask = np.zeros_like(negative_mask)
491-
negative_mask_path = tmp_path / "negative_mask.png"
491+
negative_mask_path = track_tmp_path / "negative_mask.png"
492492
imwrite(negative_mask_path, negative_mask)
493493
with pytest.raises(ValueError, match="No patch coordinates remain after filtering"):
494494
_ = WSIPatchDataset(

0 commit comments

Comments
 (0)