-
Notifications
You must be signed in to change notification settings - Fork 11
159 lines (152 loc) · 6.24 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: ci
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install the package
run: |
sudo apt update
sudo apt install -y libopenslide0
python -m pip install --upgrade pip setuptools wheel
python -m pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu openslide-python tiffslide
python -m pip install --editable .[dev]
- name: Run tests
run: python -m pytest --verbose tests/
test-pytorch-nightly:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install the package
run: |
sudo apt update
sudo apt install -y libopenslide0
python -m pip install --upgrade pip setuptools wheel
python -m pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
python -m pip install openslide-python tiffslide
python -m pip install --editable .[dev]
- name: Run tests
run: python -m pytest --verbose tests/
test-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Docker image
run: docker build -t wsinferimage .
- name: Run pytest in Docker image
run: |
docker run --rm --shm-size=512m --workdir /opt/wsinfer/ --entrypoint bash wsinferimage \
-c "python -m pip install -e /opt/wsinfer[dev] && python -m pytest -vx /opt/wsinfer/tests/test_all.py"
- name: Run wsinfer on a sample image in Docker
run: |
mkdir slides
cd slides
wget -q https://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/JP2K-33003-1.svs
cd ..
docker run --rm --shm-size=512m --volume $HOME:$HOME --volume $(pwd):/work --workdir /work wsinferimage run \
--wsi-dir slides/ --results-dir results/ --model breast-tumor-resnet34.tcga-brca
test -f results/run_metadata_*.json
test -f results/patches/JP2K-33003-1.h5
test -f results/model-outputs-csv/JP2K-33003-1.csv
test $(wc -l < results/model-outputs-csv/JP2K-33003-1.csv) -eq 601
test-package:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install OpenSlide on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: sudo apt update && sudo apt install -y libopenslide0
- name: Install OpenSlide on macOS
if: matrix.os == 'macos-latest'
run: brew install openslide
- name: Install the wsinfer python package
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
python -m pip install numpy openslide-python tiffslide
python -m pip install .
- name: Run 'wsinfer run' on Unix
if: matrix.os != 'windows-latest'
run: |
mkdir newdir && cd newdir
mkdir slides && cd slides
wget -q https://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/JP2K-33003-1.svs
cd ..
WSINFER_FORCE_CPU=1 wsinfer run --wsi-dir slides/ --results-dir results/ --model breast-tumor-resnet34.tcga-brca
test -f results/run_metadata_*.json
test -f results/patches/JP2K-33003-1.h5
test -f results/model-outputs-csv/JP2K-33003-1.csv
test $(wc -l < results/model-outputs-csv/JP2K-33003-1.csv) -eq 601
# FIXME: tissue segmentation has different outputs on Windows. The patch sizes
# are the same but the coordinates found are different.
- name: Run 'wsinfer run' on Windows
if: matrix.os == 'windows-latest'
run: |
mkdir newdir && cd newdir
mkdir slides && cd slides
Invoke-WebRequest -URI https://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/JP2K-33003-1.svs -OutFile JP2K-33003-1.svs
cd ..
wsinfer run --wsi-dir slides/ --results-dir results/ --model breast-tumor-resnet34.tcga-brca
Test-Path -Path results/run_metadata_*.json -PathType Leaf
Test-Path -Path results/patches/JP2K-33003-1.h5 -PathType Leaf
Test-Path -Path results/model-outputs-csv/JP2K-33003-1.csv -PathType Leaf
# test $(python -c "print(sum(1 for _ in open('results/model-outputs/JP2K-33003-1.csv')))") -eq 675
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install the package
run: |
sudo apt update
sudo apt install -y libopenslide0
python -m pip install --upgrade pip setuptools wheel
python -m pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu openslide-python tiffslide
python -m pip install -e .[all]
- name: Check types
run: python -m mypy --install-types --non-interactive wsinfer/ tests/
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install the package
run: |
sudo apt update
sudo apt install -y libopenslide0
python -m pip install --upgrade pip setuptools wheel
python -m pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu openslide-python tiffslide
python -m pip install .[docs]
- name: Build docs
run: |
cd docs
make html