-
Notifications
You must be signed in to change notification settings - Fork 1.1k
242 lines (235 loc) · 7.89 KB
/
pythonapp.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
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
# Jenkinsfile.monai-premerge
name: premerge
on:
# quick tests for pull requests and the releasing branches
push:
branches:
- dev
- main
- releasing/*
pull_request:
head_ref-ignore:
- dev
concurrency:
# automatically cancel the previously triggered workflows when there's a newer version
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# caching of these jobs:
# - docker-py3-pip- (shared)
# - ubuntu py37 pip-
# - os-latest-pip- (shared)
flake8-py3:
runs-on: ubuntu-latest
strategy:
matrix:
opt: ["codeformat", "pytype", "mypy"]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: cache weekly timestamp
id: pip-cache
run: |
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
uses: actions/cache@v4
id: cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install -r requirements-dev.txt
- name: Lint and type check
run: |
# clean up temporary files
$(pwd)/runtests.sh --build --clean
# Github actions have 2 cores, so parallelize pytype
$(pwd)/runtests.sh --build --${{ matrix.opt }} -j 2
quick-py3: # full dependencies installed tests for different OS
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macOS-latest, ubuntu-latest]
timeout-minutes: 120
steps:
- if: runner.os == 'windows'
name: Config pagefile (Windows only)
uses: al-cheb/[email protected]
with:
minimum-size: 8GB
maximum-size: 16GB
disk-root: "D:"
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Prepare pip wheel
run: |
which python
python -m pip install --upgrade pip wheel
- name: cache weekly timestamp
id: pip-cache
run: |
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
shell: bash
- name: cache for pip
uses: actions/cache@v4
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }}
- if: runner.os == 'windows'
name: Install torch cpu from pytorch.org (Windows only)
run: |
python -m pip install torch==1.13.1+cpu torchvision==0.14.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
- if: runner.os == 'Linux'
name: Install itk pre-release (Linux only)
run: |
python -m pip install --pre -U itk
- name: Install the dependencies
run: |
python -m pip install --user --upgrade pip wheel
python -m pip install torch==1.13.1 torchvision==0.14.1
cat "requirements-dev.txt"
python -m pip install -r requirements-dev.txt
python -m pip list
python setup.py develop # test no compile installation
shell: bash
- name: Run compiled (${{ runner.os }})
run: |
python setup.py develop --uninstall
BUILD_MONAI=1 python setup.py develop # compile the cpp extensions
shell: bash
- name: Run quick tests (CPU ${{ runner.os }})
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
env:
QUICKTEST: True
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354
packaging:
runs-on: ubuntu-latest
env:
QUICKTEST: True
shell: bash
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: cache weekly timestamp
id: pip-cache
run: |
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
uses: actions/cache@v4
id: cache
with:
path: |
~/.cache/pip
~/.cache/torch
key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
- name: Install dependencies
run: |
python -m pip install --user --upgrade pip setuptools wheel twine
# 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>=1.9 torchvision
- 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
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: |
# install from tar.gz
name=$(ls *.tar.gz | head -n1)
echo $name
python -m pip install $name[all]
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 -r requirements-dev.txt
python -m unittest -v
env:
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: cache weekly timestamp
id: pip-cache
run: |
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
uses: actions/cache@v4
id: cache
with:
path: |
~/.cache/pip
~/.cache/torch
key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install -r docs/requirements.txt
- name: Make html
run: |
cd docs/
make clean
make html 2>&1 | tee tmp_log
if [[ $(grep -c "ERROR:" tmp_log) != 0 ]]; then echo "found errors"; grep "ERROR:" tmp_log; exit 1; fi
sed '/WARNING.*pip/d' tmp_log > tmp_log1; mv tmp_log1 tmp_log # monai#7133
if [[ $(grep -c "WARNING:" tmp_log) != 0 ]]; then echo "found warnings"; grep "WARNING:" tmp_log; exit 1; fi
shell: bash