-
Notifications
You must be signed in to change notification settings - Fork 12
373 lines (320 loc) · 11.5 KB
/
test-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
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
name: CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.10"
BART_VERSION: "0.8.00"
ref_backend: "finufft"
jobs:
test-cpu:
runs-on: cpu
if: ${{ !contains(github.event.head_commit.message, '[style]') || github.ref == 'refs/heads/master' }}
strategy:
matrix:
backend: [finufft, pynfft, pynufft-cpu, bart, sigpy, torchkbnufft-cpu]
exclude:
- backend: bart
- backend: pynufft-cpu
- backend: torchkbnufft-cpu
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Dependencies
shell: bash
run: |
python --version
- name: Install Python Deps
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install -e .[test]
- name: Install pynfft
if: ${{ matrix.backend == 'pynfft' || env.ref_backend == 'pynfft' }}
shell: bash
run: |
python -m pip install "pynfft2>=1.4.3"
- name: Install pynufft
if: ${{ matrix.backend == 'pynufft-cpu' || env.ref_backend == 'pynufft-cpu' }}
run: python -m pip install pynufft
- name: Install finufft
if: ${{ matrix.backend == 'finufft' || env.ref_backend == 'finufft'}}
shell: bash
run: python -m pip install finufft
- name: Install Sigpy
if: ${{ matrix.backend == 'sigpy' || env.ref_backend == 'sigpy'}}
shell: bash
run: python -m pip install sigpy
- name: Install BART
if: ${{ matrix.backend == 'bart' || env.ref_backend == 'bart'}}
shell: bash
run: |
cd $RUNNER_WORKSPACE
sudo apt-get install make gcc libfftw3-dev liblapacke-dev libpng-dev libopenblas-dev
wget https://github.com/mrirecon/bart/archive/v${{ env.BART_VERSION }}.tar.gz
tar xzvf v${{ env.BART_VERSION }}.tar.gz
cd bart-${{ env.BART_VERSION }}
make
echo $PWD >> $GITHUB_PATH
- name: Install torchkbnufft-cpu
if: ${{ matrix.backend == 'torchkbnufft-cpu' || env.ref_backend == 'torchkbnufft-cpu'}}
run: python -m pip install torchkbnufft
- name: Run Tests
shell: bash
run: |
export COVERAGE_FILE=coverage_${{ matrix.backend }}
pytest -k='operators' --backend ${{ matrix.backend }} --ref ${{ env.ref_backend }} --cov --disable-pytest-warnings --cov-branch --cov-report=term
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage_${{ matrix.backend }}
path: coverage_${{ matrix.backend }}
test-gpu:
runs-on: gpu
if: ${{ !contains(github.event.head_commit.message, '[style]') || github.ref == 'refs/heads/master' }}
strategy:
matrix:
backend: [cufinufft, gpunufft, torchkbnufft-gpu, tensorflow]
exclude:
# There is an issue with tensorflow and cupy. This was working. See #156
- backend: tensorflow
steps:
- uses: actions/checkout@v4
- name: Install mri-nufft and finufft
shell: bash
run: |
cd $RUNNER_WORKSPACE
python --version
python -m venv venv
source $RUNNER_WORKSPACE/venv/bin/activate
pip install --upgrade pip wheel
pip install -e mri-nufft[test]
pip install cupy-cuda12x finufft "numpy<2.0"
- name: Install torch with CUDA 12.1
shell: bash
if: ${{ matrix.backend != 'tensorflow'}}
run: |
source $RUNNER_WORKSPACE/venv/bin/activate
pip install torch
- name: Install backend
shell: bash
run: |
source $RUNNER_WORKSPACE/venv/bin/activate
export CUDA_BIN_PATH=/usr/local/cuda-12.1/
export PATH=/usr/local/cuda-12.1/bin/:${PATH}
export LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64/:${LD_LIBRARY_PATH}
if [[ ${{ matrix.backend }} == "torchkbnufft-gpu" ]]; then
pip install torchkbnufft
elif [[ ${{ matrix.backend }} == "tensorflow" ]]; then
pip install tensorflow-mri==0.21.0 tensorflow-probability==0.17.0 tensorflow-io==0.27.0 matplotlib==3.7
elif [[ ${{ matrix.backend }} == "cufinufft" ]]; then
pip install "cufinufft<2.3"
else
pip install ${{ matrix.backend }}
fi
- name: Run Tests
shell: bash
run: |
cd $RUNNER_WORKSPACE/mri-nufft
source $RUNNER_WORKSPACE/venv/bin/activate
export COVERAGE_FILE=coverage_${{ matrix.backend }}
python -m pytest -k='operators' --ref ${{ env.ref_backend }} --backend ${{ matrix.backend }} --disable-pytest-warnings --cov --cov-branch --cov-report=term
- name: Upload coverage
if: success()
uses: actions/upload-artifact@v4
with:
name: coverage_${{ matrix.backend }}
path: coverage_${{ matrix.backend }}
- name: Cleanup
if: always()
shell: bash
run: |
cd $RUNNER_WORKSPACE
ls -al
rm -rf finufft
rm -rf gpuNUFFT
rm -rf venv
get-commit-message:
runs-on: ubuntu-latest
outputs:
message: ${{ steps.get_commit_message.outputs.message }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Get commit message
id: get_commit_message
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
echo "Commit message $COMMIT_MESSAGE"
echo "::set-output name=message::$COMMIT_MESSAGE"
test-examples:
runs-on: gpu
needs: get-commit-message
if: ${{ !contains(needs.get-commit-message.outputs.message, '[style]') || github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Restore cached brainweb-dl directory
uses: actions/cache/restore@v4
id: cache-restore
with:
path: ~/.cache/brainweb
key: ${{ runner.os }}-Brainweb
- name: Install Python deps
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install -e .[extra,test,dev]
python -m pip install finufft pooch brainweb-dl torch fastmri
- name: Install GPU related interfaces
run: |
export CUDA_BIN_PATH=/usr/local/cuda-12.1/
export PATH=/usr/local/cuda-12.1/bin/:${PATH}
export LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64/:${LD_LIBRARY_PATH}
pip install cupy-cuda12x torch
python -m pip install gpuNUFFT "cufinufft<2.3" sigpy scikit-image fastmri
- name: Run examples
shell: bash
run: |
export COVERAGE_FILE=coverage_plots
pytest examples tests -k="not operators" --cov --cov-branch --cov-report=term
- name: Cache brainweb-dl directory
uses: actions/cache/save@v4
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
with:
path: ~/.cache/brainweb
key: ${{ runner.os }}-Brainweb
- name: Upload coverage
if: success()
uses: actions/upload-artifact@v4
with:
name: coverage_plots
path: coverage_plots
coverage:
runs-on: ubuntu-latest
needs: [test-cpu, test-gpu, test-examples]
if: ${{ always() }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Collect Coverages
uses: actions/download-artifact@v4
with:
path: coverage_data
pattern: coverage_*
merge-multiple: true
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: add the coverage tool
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install coverage[toml]
python -m pip install -e .
- name: Combine coverage
run: |
export COVERAGE_FILE=coverage_combined
coverage combine -a coverage_data/*
- name: Upload Combined coverage
uses: actions/upload-artifact@v4
with:
name: coverage_combined
path: coverage_combined
- name: Reports
run: |
export COVERAGE_FILE=coverage_combined
coverage xml
coverage report
echo COVERAGE_PERC=$(coverage report | tail -n 1 | grep -oE [0-9\.]*?% | cut -d '%' -f1) >> $GITHUB_ENV
- name: Create a Coverage Badge
if: ${{github.event_name == 'push'}}
run: |
wget https://img.shields.io/badge/coverage-${{env.COVERAGE_PERC}}%25-green -O coverage_badge.svg
- name: Upload badge as artifact
if: ${{github.event_name == 'push'}}
uses: actions/upload-artifact@v4
with:
name: coverage_badge
path: coverage_badge.svg
BuildDocs:
name: Build API Documentation
runs-on: gpu
needs: get-commit-message
if: ${{ contains(needs.get-commit-message.outputs.message, '[docs]') || github.ref == 'refs/heads/master' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
python -m pip install .[doc]
python -m pip install finufft
- name: Install GPU related interfaces
run: |
export CUDA_BIN_PATH=/usr/local/cuda-12.1/
export PATH=/usr/local/cuda-12.1/bin/:${PATH}
export LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64/:${LD_LIBRARY_PATH}
pip install cupy-cuda12x torch
python -m pip install gpuNUFFT "cufinufft<2.3"
- name: Build API documentation
run: |
python -m sphinx docs docs_build
- name: Display data
run: ls -R
working-directory: docs_build/_static
- name: Upload artifact
id: artifact-upload-step
uses: actions/upload-artifact@v4
with:
# Upload the docs
name: docs
path: 'docs_build'
retention-days: 5
CompileDocs:
name: Compile the coverage badge in docs
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
needs: [BuildDocs, coverage]
steps:
- name: Get the docs_build artifact
uses: actions/download-artifact@v4
with:
name: docs
path: docs_build
overwrite: true
- name: Get the badge from CI
uses: actions/download-artifact@v4
with:
name: coverage_badge
path: docs_build/_static
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: ReUpload artifacts
uses: actions/upload-artifact@v4
with:
name: docs_final
retention-days: 20
path: docs_build