-
Notifications
You must be signed in to change notification settings - Fork 13
256 lines (224 loc) · 7.22 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
name: CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
env:
PYTHON_VERSION: "3.10"
BART_VERSION: "0.8.00"
jobs:
linter-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Black setup
shell: bash
run: pip install black ruff
- name: Black Check
shell: bash
run: black . --diff --color --check
- name: ruff Check
shell: bash
run: ruff src
test-cpu:
runs-on: ubuntu-latest
needs: linter-check
strategy:
fail-fast: true
matrix:
backend: [finufft, pynfft, bart, sigpy]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Dependencies
shell: bash
run: |
sudo apt install -y libnfft3-dev
python --version
python -m pip install --upgrade pip
python -m pip install -e .[test]
- name: Install pynfft
shell: bash
run: |
python -m pip pynfft2 "cython<3.0.0"
- name: Install finufft
if: matrix.backend == "finufft"
shell: bash
run: |
python -m pip install finufft
- name: Install Sigpy
if: matrix.backend == "sigpy"
run: python -m pip install sigpy
- name: Install BART
if: matrix.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
- name: Run Tests
shell: bash
run: |
coverage run -m pytest -n auto -v
coverage report
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage-cpu-${{ github.sha }}
path: .coverage
#https://stackoverflow.com/a/74411469/16019838
- name: Abort other jobs
if: failure()
uses: actions/github-script@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_RUN_ID: ${{ github.run_id }}
with:
script: |
const RUN_ID = process.env.GITHUB_RUN_ID
const [OWNER, REPO] = process.env.GITHUB_REPOSITORY.split("/");
const resp = await github.request('POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel', {
owner: OWNER,
repo: REPO,
run_id: RUN_ID,
headers: {'X-GitHub-Api-Version': '2022-11-28'}})
test-gpu:
runs-on: GPU
needs: linter-check
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v3
- name: Install mri-nufft
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]
- name: Install Cufinufft
shell: bash
run: |
cd $RUNNER_WORKSPACE
rm -rf finufft
git clone https://github.com/chaithyagr/finufft --branch chaithyagr/issue306
cd finufft && mkdir build && cd build
export PATH=/usr/local/cuda-11.8/bin:$PATH
export CUDA_PATH=/usr/local/cuda-11.8
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH
export CUDA_BIN_PATH=/usr/local/cuda-11.8
cmake -DFINUFFT_USE_CUDA=1 ../ && cmake --build . && cp libcufinufft.so ../python/cufinufft/.
# enter venv
source $RUNNER_WORKSPACE/venv/bin/activate
pip install cupy-cuda11x
cd $RUNNER_WORKSPACE/finufft/python/cufinufft
python setup.py develop
# FIXME: This is hardcoded
cp libcufinufft.so cufinufftc.cpython-310-x86_64-linux-gnu.so
cd $RUNNER_WORKSPACE
- name: Install gpuNUFFT
shell: bash
run: |
cd $RUNNER_WORKSPACE
rm -rf gpuNUFFT
git clone https://github.com/chaithyagr/gpuNUFFT
cd gpuNUFFT
export PATH=/usr/local/cuda-11.8/bin:$PATH
export CUDA_PATH=/usr/local/cuda-11.8
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH
export CUDA_BIN_PATH=/usr/local/cuda-11.8
source $RUNNER_WORKSPACE/venv/bin/activate
python setup.py install
- name: Run Tests
shell: bash
run: |
cd $RUNNER_WORKSPACE/mri-nufft
source $RUNNER_WORKSPACE/venv/bin/activate
python -m coverage run -m pytest -n auto -v
coverage report
- name: Upload coverage
if: success()
uses: actions/upload-artifact@v3
with:
name: coverage-gpu-${{ github.sha }}
path: .coverage
#https://stackoverflow.com/a/74411469/16019838
#
- name: Abort other jobs
if: failure()
uses: actions/github-script@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_RUN_ID: ${{ github.run_id }}
with:
script: |
const RUN_ID = process.env.GITHUB_RUN_ID
const [OWNER, REPO] = process.env.GITHUB_REPOSITORY.split("/");
const resp = await github.request('POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel', {
owner: OWNER,
repo: REPO,
run_id: RUN_ID,
headers: {'X-GitHub-Api-Version': '2022-11-28'}})
- name: Cleanup
if: always()
shell: bash
run: |
cd $RUNNER_WORKSPACE
ls -al
rm -rf finufft
rm -rf gpuNUFFT
rm -rf venv
coverage:
runs-on: ubuntu-latest
needs: [test-cpu, test-gpu]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download coverage CPU
uses: actions/download-artifact@v3
with:
name: coverage-cpu-${{ github.sha }}
path: cov-cpu
- name: Download coverage GPU
uses: actions/download-artifact@v3
with:
name: coverage-gpu-${{ github.sha }}
path: cov-gpu
- name: Set up Python 3.10
uses: actions/setup-python@v4
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
shell: bash
run: |
coverage combine cov-cpu/.coverage cov-gpu/.coverage
coverage xml -i
coverage report
ls -al
- name: Upload Join
if: success()
uses: actions/upload-artifact@v3
with:
name: coverage-full-${{ github.sha}}
path: .coverage