This repository was archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
295 lines (242 loc) · 8.91 KB
/
pr.yml
File metadata and controls
295 lines (242 loc) · 8.91 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
# Copyright 2021 MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: build
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
docker_build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
monaistream_docker_image_tag: ${{ steps.findPr.outputs.pr }}
steps:
- name: Checkout Source Code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to NGC
uses: docker/login-action@v1.10.0
with:
registry: nvcr.io
username: ${{ secrets.NGC_USER }}
password: ${{ secrets.NGC_TOKEN }}
- uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
state: all
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3.5.0
with:
images: nvcr.io/nv-monai/monai-internal/monaistream:${{ steps.findPr.outputs.pr }}
- name: Check if Docker Image with Tag Exists
id: docker_build_check
run: |
if docker manifest inspect "nvcr.io/nv-monai/monai-internal/monaistream:${{ steps.findPr.outputs.pr }}"; then
echo "::set-output name=skip_docker_build::true"
else
echo "::set-output name=skip_docker_build::false"
fi
- name: Build and Push MONAI SDK Development Docker Image
if: steps.docker_build_check.outputs.skip_docker_build == 'false'
uses: docker/build-push-action@v2.7.0
with:
context: .
push: true
tags: nvcr.io/nv-monai/monai-internal/monaistream:${{ steps.findPr.outputs.pr }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile.base
build:
needs: docker_build
runs-on: ubuntu-latest
container:
image: "docker://nvcr.io/nv-monai/monai-internal/monaistream:${{ needs.docker_build.outputs.monaistream_docker_image_tag }}"
credentials:
username: ${{ secrets.NGC_USER }}
password: ${{ secrets.NGC_TOKEN }}
steps:
- name: Checkout Source Code
uses: actions/checkout@v2
- name: Install PyDS Library
run: |
cp ./lib/pyds-py3.8-x86.so /opt/nvidia/deepstream/deepstream-6.0/lib/pyds.so
pushd /opt/nvidia/deepstream/deepstream-6.0/lib
python setup.py install
popd
- name: Install MONAIStream Requirements
run: |
python -m pip install -r requirements-dev.txt
- name: Clean
run: |
./runtests.sh --clean
- name: ISort
run: |
./runtests.sh --isort
- name: Black
run: |
./runtests.sh --black
- name: Flake8
run: |
./runtests.sh --flake8
- name: PyType
run: |
./runtests.sh --pytype
- name: MyPy
run: |
./runtests.sh --mypy
unittest_agx:
runs-on: agx
steps:
- name: Checkout Source Code
uses: actions/checkout@v2
- name: Install dependencies
run: |
python3 -m pip install -r requirements-dev.txt --user
- name: Unit Tests
run: |
# setup data
export tmp_data_dir=$(mktemp -d)
pushd $tmp_data_dir
wget https://github.com/Project-MONAI/MONAIStream/releases/download/data/US.zip
unzip US.zip -d .
popd
# convert ONNX model to TRT and setup model repo
mkdir -p $tmp_data_dir/models/monai_unet_trt/1
cp $tmp_data_dir/US/config_us_trt.pbtxt $tmp_data_dir/models/monai_unet_trt/config.pbtxt
MODEL_FILE_ONNX=$tmp_data_dir/US/us_unet_256x256.onnx
MODEL_FILE_CONVERTED=$tmp_data_dir/models/monai_unet_trt/1/monai_unet.engine
/usr/src/tensorrt/bin/trtexec --onnx=${MODEL_FILE_ONNX} --saveEngine=${MODEL_FILE_CONVERTED} --explicitBatch --verbose --workspace=5000
# run tests
export DISPLAY=:0.0
./runtests.sh --unittests --coverage
- name: Coverage
run: |
python3 -m coverage xml
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
file: ./coverage.xml
packaging:
needs: docker_build
runs-on: ubuntu-latest
container:
image: "docker://nvcr.io/nv-monai/monai-internal/monaistream:${{ needs.docker_build.outputs.monaistream_docker_image_tag }}"
credentials:
username: ${{ secrets.NGC_USER }}
password: ${{ secrets.NGC_TOKEN }}
steps:
- name: Checkout Source Code
uses: actions/checkout@v2
- name: Install PyDS Library
run: |
cp ./lib/pyds-py3.8-x86.so /opt/nvidia/deepstream/deepstream-6.0/lib/pyds.so
pushd /opt/nvidia/deepstream/deepstream-6.0/lib
python setup.py install
popd
- name: Install MONAIStream Requirements
run: |
python -m pip install -r requirements-dev.txt
- name: cache weekly timestamp
id: pip-cache
run: |
echo "::set-output name=datew::$(date '+%Y-%V')"
- name: cache for pip
uses: actions/cache@v2
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
python -m pip install torch>=1.8 torchvision
- name: Test source archive and wheel file
run: |
root_dir=$PWD
echo "$root_dir"
# build tar.gz and wheel
python setup.py check -m -s
python setup.py sdist bdist_wheel
python -m twine check dist/*
# move packages to a temp dir
tmp_dir=$(mktemp -d)
cp dist/monaistream* "$tmp_dir"
rm -r build dist src/monaistream.egg-info
cd "$tmp_dir"
ls -al
# install from wheel
python -m pip install monaistream*.whl
python -c 'import monaistream; monaistream.print_config()' 2>&1 | grep -iv "unknown"
python -c 'import monaistream; print(monaistream.__file__)'
python -m pip uninstall -y monaistream
rm monaistream*.whl
# install from tar.gz
name=$(ls *.tar.gz | head -n1)
echo $name
python -m pip install $name
python -c 'import monaistream; monaistream.print_config()' 2>&1 | grep -iv "unknown"
python -c 'import monaistream; print(monaistream.__file__)'
env:
shell: bash
build-docs:
needs: docker_build
runs-on: ubuntu-latest
container:
image: "docker://nvcr.io/nv-monai/monai-internal/monaistream:${{ needs.docker_build.outputs.monaistream_docker_image_tag }}"
credentials:
username: ${{ secrets.NGC_USER }}
password: ${{ secrets.NGC_TOKEN }}
steps:
- name: Checkout Source Code
uses: actions/checkout@v2
- name: Install PyDS Library
run: |
cp ./lib/pyds-py3.8-x86.so /opt/nvidia/deepstream/deepstream-6.0/lib/pyds.so
pushd /opt/nvidia/deepstream/deepstream-6.0/lib
python setup.py install
popd
- name: cache weekly timestamp
id: pip-cache
run: |
echo "::set-output name=datew::$(date '+%Y-%V')"
- name: cache for pip
uses: actions/cache@v2
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: |
export PYTHONPATH=$(pwd)/src
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/compat/lib.real
cd docs/
make clean
make html 2>&1 | tee tmp_log
if [[ $(grep -c "WARNING:" tmp_log) != 0 ]]; then echo "found warnings"; grep "WARNING:" tmp_log; exit 1; fi
shell: bash