-
Notifications
You must be signed in to change notification settings - Fork 1.5k
317 lines (303 loc) · 11.5 KB
/
cicd_tests.yml
File metadata and controls
317 lines (303 loc) · 11.5 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
name: tests
on:
# quick tests for pull requests and the releasing branches
push:
branches:
- dev
- main
- releasing/*
paths-ignore: # skip if only docs are modified
- '**.md'
- '**.rst'
- 'docs/**'
pull_request:
branches:
- dev
- main
- releasing/*
paths-ignore: # skip if only docs are modified
- '**.md'
- '**.rst'
- 'docs/**'
concurrency:
# automatically cancel the previously triggered workflows when there's a newer version
group: cicd-tests-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# Supported versions of Python and PyTorch are listed here for use below and as documentation
env:
# supported versions of Python
PYTHON_VER1: '3.10'
PYTHON_VER2: '3.11'
PYTHON_VER3: '3.12'
PYTHON_VER4: '3.13'
# PYTHON_VER5: '3.14' # TODO: not compatible with Torchscript, re-enable once Torchscript removed from MONAI
# supported versions of PyTorch
PYTORCH_VER1: '2.8.0'
PYTORCH_VER2: '2.9.1'
PYTORCH_VER3: '2.10.0'
PYTORCH_VER4: '2.11.0'
TORCHVISION_VER1: '0.23.0' # used for testing with lowest PyTorch version (PYTORCH_VER1), update as needed
# versions of PyTorch/Torchvision to use for full-dep Windows tests, needed to get around a gloo bug
WIN_FULLDEP_VER: '2.11.0'
WIN_FULLDEP_VISION_VER: '0.26.0'
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354
# These jobs run the CICD tests, type checking, and testing packaging. These use the minimum supported versions of
# Python and PyTorch in many places using the above environment variables but also hard coded where necessary.
# When support is dropped for a version it is important to update these as appropriate.
jobs:
static-checks: # Perform static type and other checks using runtests.sh
runs-on: ubuntu-latest
strategy:
matrix:
opt: ["codeformat", "pytype", "mypy"]
steps:
- name: Clean unused tools
run: |
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc /usr/local/.ghcup
sudo docker system prune -f
- uses: actions/checkout@v6
- name: Set up Python ${{ env.PYTHON_VER1 }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VER1 }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install --no-build-isolation -r requirements-dev.txt
- name: Lint and type check
run: |
# clean up temporary files
$(pwd)/runtests.sh --build --clean
# Github actions have multiple cores, so parallelize pytype
$(pwd)/runtests.sh --build --${{ matrix.opt }} -j $(nproc --all)
min-dep: # Test with minumum dependencies installed for different OS, Python, and PyTorch combinations
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Base test cases are to test on all three OSes with the lowest versions of Python and PyTorch, other cases are
# added below as special cases to cover other Python and PyTorch versions under Ubuntu
os: [windows-latest, macOS-latest, ubuntu-latest]
python-version: ['3.10']
pytorch-version: ['2.8.0']
include:
# Test Python versions under Ubuntu with lowest PyTorch version supported
- os: ubuntu-latest
pytorch-version: '2.8.0'
python-version: '3.11'
- os: ubuntu-latest
pytorch-version: '2.8.0'
python-version: '3.12'
- os: ubuntu-latest
pytorch-version: '2.8.0'
python-version: '3.13'
# - os: ubuntu-latest
# pytorch-version: '2.9.1'
# python-version: '3.14'
# Test PyTorch versions under Ubuntu with lowest Python version supported
- os: ubuntu-latest
python-version: '3.10'
pytorch-version: '2.9.1'
- os: ubuntu-latest
python-version: '3.10'
pytorch-version: '2.10.0'
- os: ubuntu-latest
python-version: '3.10'
pytorch-version: '2.11.0'
timeout-minutes: 40
steps:
- if: runner.os == 'Linux'
name: Clean unused tools
run: |
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc /usr/local/.ghcup
sudo docker system prune -f
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Prepare pip wheel
run: |
which python
python -m pip install --upgrade pip wheel
python -m pip install --user more-itertools>=8.0
- name: Install the minimum dependencies
run: |
# min. requirements
python -m pip install torch==${{ matrix.pytorch-version }}
python -m pip install -r requirements-min.txt
python -m pip list
BUILD_MONAI=0 python setup.py develop # no compile of extensions
shell: bash
- if: matrix.os == 'linux-gpu-runner'
name: Print GPU Info
run: |
nvidia-smi
python -c 'import torch; print(torch.rand(2,2).to("cuda:0"))'
shell: bash
- name: Run quick tests
run: |
python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
python -c "import monai; monai.config.print_config()"
./runtests.sh --min
shell: bash
env:
QUICKTEST: True
NGC_API_KEY: ${{ secrets.NGC_API_KEY }}
NGC_ORG: ${{ secrets.NGC_ORG }}
NGC_TEAM: ${{ secrets.NGC_TEAM }}
full-dep: # Test with full dependencies installed for different OS runners
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macOS-latest, ubuntu-latest]
timeout-minutes: 120
env:
QUICKTEST: True
steps:
- if: runner.os == 'Linux'
name: Clean unused tools
run: |
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc /usr/local/.ghcup
sudo docker system prune -f
- if: runner.os == 'windows'
name: Config pagefile (Windows only)
uses: al-cheb/configure-pagefile-action@v1.5
with:
minimum-size: 8GB
maximum-size: 16GB
disk-root: "D:"
- uses: actions/checkout@v6
- name: Set up Python ${{ env.PYTHON_VER1 }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VER1 }}
cache: 'pip'
- name: Prepare pip wheel
run: |
which python
python -m pip install --upgrade pip wheel
- if: runner.os == 'windows'
name: Install torch cpu from pytorch.org (Windows only)
run: |
python -m pip install torch==${WIN_FULLDEP_VER} torchvision==${WIN_FULLDEP_VISION_VER}+cpu --index-url https://download.pytorch.org/whl/cpu
shell: bash
- if: runner.os != 'windows'
name: Install torch gpu
run: |
# install the lowest version of PyTorch supported
python -m pip install torch==${PYTORCH_VER1} torchvision==${TORCHVISION_VER1}
shell: bash
- if: runner.os == 'Linux'
name: Install itk pre-release (Linux only)
run: |
python -m pip install --pre -U itk
shell: bash
- name: Install the complete dependencies
run: |
python -m pip install --user --upgrade pip wheel pybind11 # TODO: pybind11 added for macOS, may not be needed
#python -m pip install torch==${PYTORCH_VER1} torchvision==${TORCHVISION_VER1}
cat "requirements-dev.txt"
python -m pip install --no-build-isolation -r requirements-dev.txt
python -m pip list
python -m pip install -e . # test no compile installation
shell: bash
- name: Run compiled (${{ runner.os }})
run: |
python -m pip uninstall -y monai
BUILD_MONAI=1 python -m pip install -e . # compile the cpp extensions
shell: bash
- name: Run quick tests
run: |
python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
python -c "import monai; monai.config.print_config()"
python -m unittest -v
shell: bash
packaging: # Test package generation
runs-on: ubuntu-latest
env:
QUICKTEST: True
steps:
- name: Clean unused tools
run: |
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc /usr/local/.ghcup
sudo docker system prune -f
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_VER1 }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VER1 }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --user --upgrade pip setuptools wheel twine packaging
# install the latest pytorch for testing
# however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated
# fresh torch installation according to pyproject.toml
python -m pip install torch==${PYTORCH_VER1} torchvision --extra-index-url https://download.pytorch.org/whl/cpu
- name: Check packages
run: |
pip uninstall monai
pip list | grep -iv monai
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
set -e
# build tar.gz and wheel
python setup.py check -m -s
python setup.py sdist bdist_wheel
python -m twine check dist/*
- run: echo "pwd=$PWD" >> $GITHUB_OUTPUT
id: root
- run: echo "tmp_dir=$(mktemp -d)" >> $GITHUB_OUTPUT
id: mktemp
- name: Move packages
run: |
printf ${{ steps.root.outputs.pwd }}
printf ${{ steps.mktemp.outputs.tmp_dir }}
# move packages to a temp dir
cp dist/monai* "${{ steps.mktemp.outputs.tmp_dir }}"
rm -r build dist monai.egg-info
cd "${{ steps.mktemp.outputs.tmp_dir }}"
ls -al
- name: Install wheel file
working-directory: ${{ steps.mktemp.outputs.tmp_dir }}
run: |
# install from wheel
python -m pip install monai*.whl --extra-index-url https://download.pytorch.org/whl/cpu
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
python -c 'import monai; print(monai.__file__)'
python -m pip uninstall -y monai
rm monai*.whl
- name: Install source archive
working-directory: ${{ steps.mktemp.outputs.tmp_dir }}
run: |
for name in *.tar.gz; do break; done
echo $name
python -m pip install ${name}[all] --extra-index-url https://download.pytorch.org/whl/cpu
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
python -c 'import monai; print(monai.__file__)'
- name: Quick test
working-directory: ${{ steps.mktemp.outputs.tmp_dir }}
run: |
# run min tests
cp ${{ steps.root.outputs.pwd }}/requirements*.txt .
cp -r ${{ steps.root.outputs.pwd }}/tests .
ls -al
python -m pip install --no-build-isolation -r requirements-dev.txt --extra-index-url https://download.pytorch.org/whl/cpu
python -m unittest -v