Skip to content

Commit 6caef0b

Browse files
Merge branch 'develop' of https://github.com/TIA-Lab/tiatoolbox into example-semantic
2 parents 6580921 + 748ed2a commit 6caef0b

19 files changed

+975
-157
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,30 @@ repos:
88
hooks:
99
- id: black
1010
language_version: python3 # Should be a command that runs python3.7+
11-
- repo: https://gitlab.com/pycqa/flake8
12-
rev: 3.9.2
13-
hooks:
14-
- id: flake8
15-
additional_dependencies: [
16-
flake8-spellcheck, # Spelling checker
17-
]
18-
args: [--exit-zero] # These checks will not cause the commit to fail
19-
verbose: true
2011
- repo: https://gitlab.com/pycqa/flake8
2112
rev: 3.9.2
2213
hooks:
2314
- id: flake8
2415
additional_dependencies: [
2516
flake8-bugbear, # Detect potential bugs
26-
flake8-isort, # Check import ordering
27-
flake8-comprehensions, # Suggestions for better list/set/dict comprehensions
28-
flake8-mutable, # Check for mutable default arguments
29-
flake8-use-fstring, # Encourages use of f-strings vs old style
30-
flake8-simplify, # Suggestions to simplify code
31-
pep8-naming, # Check PEP8 class naming
32-
flake8-eradicate, # Find dead/commented out code
3317
flake8-builtins, # Check for built-ins being used as variables
3418
flake8-cognitive-complexity, # Check max function complexity
19+
flake8-comprehensions, # Suggestions for better list/set/dict comprehensions
20+
flake8-eradicate, # Find dead/commented out code
3521
flake8-expression-complexity, # Check max expression complexity
36-
flake8-return, # Check return statements
37-
flake8-pytest-style, # Check against pytest style guide
3822
flake8-fixme, # Check for FIXME, TODO, and XXX left in comments
39-
flake8-sql, # Check SQL statement style
40-
nitpick, # Check that black, flake8, isort have compaible options
23+
flake8-isort, # Check import ordering
4124
flake8-logging-format, # Validate (lack of) logging format strings
25+
flake8-mutable, # Check for mutable default arguments
4226
flake8-pie, # Misc. linting rules
27+
flake8-pytest-style, # Check against pytest style guide
28+
flake8-return, # Check return statements
29+
flake8-simplify, # Suggestions to simplify code
30+
flake8-spellcheck, # Spelling checker
31+
flake8-sql, # Check SQL statement style
32+
flake8-use-fstring, # Encourages use of f-strings vs old style
33+
nitpick, # Check that black, flake8, isort have compaible options
34+
pep8-naming, # Check PEP8 class naming
4335
]
4436
- repo: local
4537
hooks:

requirements.conda.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,28 @@ dependencies:
88
- python=3.7
99
- Click
1010
- cython
11+
- defusedxml
12+
- glymur
1113
- h5py
14+
- imagecodecs
15+
- jupyterlab
1216
- matplotlib
1317
- numpy
1418
- opencv>=4.0
1519
- openjpeg>=2.3.0
20+
- openslide
21+
- pandas
1622
- pillow
1723
- pip
24+
- pixman<0.38.0
25+
- pytorch
1826
- pyyaml>=5.1
1927
- requests
20-
- pixman<0.38.0
21-
- openslide
22-
- pandas
23-
- glymur
24-
- scikit-learn>=0.23.2
2528
- scikit-image
29+
- scikit-learn>=0.23.2
30+
- tifffile
2631
- torchvision
27-
- pytorch
2832
- tqdm
29-
- jupyterlab
33+
- zarr
3034
- pip:
3135
- openslide-python==1.1.2

requirements.dev.conda.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,40 @@ channels:
55
- pytorch
66
- defaults
77
dependencies:
8-
- python=3.7
8+
- black
99
- Click
1010
- cython
11+
- defusedxml
12+
- flake8
13+
- flake8-bugbear
14+
- glymur
1115
- h5py
16+
- imagecodecs
17+
- jupyterlab
1218
- matplotlib
1319
- numpy
1420
- opencv>=4.0
21+
- openjpeg>=2.3.0
22+
- openslide
23+
- pandas
1524
- pillow
1625
- pip
17-
- pyyaml>=5.1
18-
- requests
1926
- pixman<0.38.0
20-
- openslide
21-
- openjpeg>=2.3.0
27+
- pre-commit
28+
- pytest-cov
29+
- pytest-runner==5.2
30+
- pytest==6.2.5
31+
- python=3.7
32+
- pytorch
33+
- pyyaml>=5.1
2234
- recommonmark
23-
- pandas
24-
- glymur
35+
- requests
36+
- scikit-image
2537
- scikit-learn>=0.23.2
38+
- tifffile
39+
- torchvision
2640
- torchvision>=0.10.1
27-
- pytorch
2841
- tqdm
29-
- pytest==6.2.5
30-
- pytest-runner==5.2
31-
- scikit-image
32-
- pre-commit
33-
- flake8
34-
- flake8-bugbear
35-
- black
36-
- pytest-cov
37-
- jupyterlab
38-
- openjpeg
42+
- zarr
3943
- pip:
4044
- openslide-python==1.1.2

requirements.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
Click>=7.0
2-
numpy
3-
pillow
2+
defusedxml
3+
glymur
4+
imagecodecs
5+
jupyterlab
46
matplotlib
7+
numpy
58
opencv-python>=4.0
69
openslide-python==1.1.2
7-
pyyaml>=5.1
810
pandas
9-
glymur
10-
scikit-learn>=0.23.2
11+
pillow
12+
pyyaml>=5.1
13+
requests
1114
scikit-image
15+
scikit-learn>=0.23.2
1216
sphinx==4.1.2
17+
tifffile
1318
torchvision==0.10.1
1419
torch==1.9.1
1520
tqdm==4.60.0
1621
jupyterlab
1722
requests
23+
zarr

requirements.win64.conda.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,27 @@ dependencies:
88
- python=3.7
99
- Click
1010
- cython
11+
- defusedxml
12+
- glymur
1113
- h5py
14+
- imagecodecs
15+
- jupyterlab
1216
- matplotlib
1317
- numpy
1418
- opencv>=4.0
19+
- pandas
1520
- pillow
1621
- openjpeg>=2.3.0
1722
- pip
23+
- pixman<0.38.0
24+
- pytorch
1825
- pyyaml>=5.1
1926
- requests
20-
- pixman<0.38.0
21-
- pandas
22-
- glymur
23-
- scikit-learn>=0.23.2
2427
- scikit-image
28+
- scikit-learn>=0.23.2
29+
- tifffile
2530
- torchvision
26-
- pytorch
2731
- tqdm
28-
- jupyterlab
32+
- zarr
2933
- pip:
3034
- openslide-python

requirements_dev.txt

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
1-
pip>=20.0.2
1+
black
22
bump2version==0.5.11
3-
wheel==0.33.6
4-
watchdog==0.9.0
5-
flake8==3.7.8
6-
tox==3.14.0
7-
coverage==5.1
8-
sphinx==4.1.2
9-
twine==1.14.0
103
Click>=7.0
11-
pytest==6.2.5
12-
pytest-runner==5.2
4+
coverage==5.1
5+
flake8==3.7.8
6+
flake8-bugbear
7+
glymur
8+
imagecodecs
9+
jupyterlab
10+
matplotlib
11+
numpy
1312
opencv-python>=4.0
1413
openslide-python==1.1.2
15-
pytest-cov==2.9.0
16-
numpy
14+
pandas
15+
pip>=20.0.2
1716
pillow
18-
matplotlib
17+
pre-commit
18+
pytest==6.2.5
19+
pytest-runner==5.2
20+
pytest-cov==2.9.0
1921
pyyaml>=5.1
20-
pandas
21-
glymur
22+
recommonmark
23+
requests
2224
scikit-image
2325
scikit-learn>=0.23.2
24-
recommonmark
25-
pre-commit
26-
black
27-
flake8-bugbear
28-
torchvision==0.10.1
26+
sphinx==4.1.2
27+
tifffile
28+
tox==3.14.0
2929
torch==1.9.1
30+
torchvision==0.10.1
3031
tqdm==4.60.0
31-
jupyterlab
32-
requests
32+
twine==1.14.0
33+
wheel==0.33.6
34+
watchdog==0.9.0
35+
zarr

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ max-line-length = 88
2020
extend-ignore = E203 # For black compatibility
2121
spellcheck-targets = comments
2222
dictionaries = en_US,python,technical
23-
max-cognitive-complexity = 7
23+
max-cognitive-complexity = 11
2424
max-expression-complexity = 7
2525

2626
[aliases]

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
"torchvision==0.10.1",
2626
"torch==1.9.1",
2727
"tqdm==4.60.0",
28+
"tifffile",
29+
"imagecodecs",
30+
"zarr",
2831
"requests",
2932
]
3033

tests/models/test_abc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from tiatoolbox.models.architecture import get_pretrained_model
2828

2929

30+
@pytest.mark.skip(reason="Local test, not applicable for travis.")
3031
def test_get_pretrained_model():
3132
"""Test for downloading and creating pretrained models."""
3233
pretrained_info = rcParam["pretrained_model_info"]

tests/test_data.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,48 @@ def test_fetch_sample(tmp_path):
1717
tmp_path = pathlib.Path(tmp_path)
1818
path = _fetch_remote_sample("stainnorm-source")
1919
assert os.path.exists(path)
20-
# test if corrupted
20+
# Test if corrupted
2121
get_wsireader(path)
2222

2323
path = _fetch_remote_sample("stainnorm-source", tmp_path)
24-
# assuming Path has no trailing '/'
24+
# Assuming Path has no trailing '/'
2525
assert os.path.exists(path)
2626
assert str(tmp_path) in str(path)
2727

28-
# test not directory path
28+
# Test not directory path
2929
test_path = pathlib.Path(f"{tmp_path}/dummy.npy")
3030
np.save(test_path, np.zeros([3, 3, 3]))
3131
with pytest.raises(ValueError, match=r".*tmp_path must be a directory.*"):
3232
path = _fetch_remote_sample("wsi1_8k_8k_svs", test_path)
3333

34-
# very tiny so temporary hook here also
34+
# Very tiny so temporary hook here also
35+
arr = stainnorm_target()
36+
assert isinstance(arr, np.ndarray)
37+
38+
39+
def test_fetch_sample_skip(tmp_path):
40+
"""Test skipping fetching sample via code name if already downloaded."""
41+
# Fetch the remote file twice
42+
tmp_path = pathlib.Path(tmp_path)
43+
path_a = _fetch_remote_sample("wsi1_8k_8k_svs")
44+
path_b = _fetch_remote_sample("wsi1_8k_8k_svs")
45+
assert os.path.exists(path_a)
46+
assert path_a == path_b
47+
# Test if corrupted
48+
get_wsireader(path_a)
49+
50+
path = _fetch_remote_sample("wsi1_8k_8k_svs", tmp_path)
51+
# Assuming Path has no trailing '/'
52+
assert os.path.exists(path)
53+
assert str(tmp_path) in str(path)
54+
55+
# Test not directory path
56+
test_path = pathlib.Path(f"{tmp_path}/dummy.npy")
57+
np.save(test_path, np.zeros([3, 3, 3]))
58+
with pytest.raises(ValueError, match=r".*tmp_path must be a directory.*"):
59+
path = _fetch_remote_sample("wsi1_8k_8k_svs", test_path)
60+
61+
# Very tiny so temporary hook here also
3562
arr = stainnorm_target()
3663
assert isinstance(arr, np.ndarray)
3764

0 commit comments

Comments
 (0)