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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
version: 2.1
parameters:
remote_docker_version:
type: string
description: remote docker version
default: "20.10.18"
orb_version:
type: string
description: Deci ai ORB version https://circleci.com/developer/orbs/orb/deci-ai/circleci-common-orb
default: "10.3.1"
# default: "dev:alpha"
orbs:
deci-common: deci-ai/circleci-common-orb@<< pipeline.parameters.orb_version >>
aws-ecr: circleci/aws-ecr@8.2.1
docker: circleci/docker@2.2.0
slack: circleci/slack@4.12.0 # see https://circleci.com/developer/orbs/orb/circleci/slack for examples and more
# This filter operates on SemVer2 tags only
release_tag_filter: &release_tag_filter
filters:
branches:
ignore: /.*/
tags:
only: /^\d+\.\d+\.\d+$/
release_candidate_filter: &release_candidate_filter
filters:
branches:
only: master
release_candidate_tag_filter: &release_candidate_tag_filter
filters:
branches:
ignore: /.*/
tags:
only: /^\d+\.\d+\.\d+rc\d+/
commands:
get_beta_and_rc_tags:
description: "getting beta and rc tag (if exist) according to ouir convention"
steps:
- attach_workspace:
at: ~/
- run:
name: push BETA_TAG and RC_TAG variable to BASH_ENV
command: |
if [[ -f ~/BETA_TAG ]]; then
echo 'export BETA_TAG="$(cat ~/BETA_TAG)"' >> "$BASH_ENV"
fi
if [[ -f ~/RC_TAG ]]; then
echo 'export RC_TAG="$(cat ~/RC_TAG)"' >> "$BASH_ENV"
fi
source $BASH_ENV
echo "RC_TAG=$RC_TAG || BETA_TAG=$BETA_TAG"
adding_tag_to_ecr_container_image:
description: adding a tag to an existing container image
parameters:
image_repo:
type: string
new_image_tag:
type: string
source_image_tag:
type: string
steps:
- deci-common/run_on_dev_account:
command: |
MANIFEST=$(aws ecr batch-get-image --repository-name << parameters.image_repo >> --image-ids imageTag=<< parameters.source_image_tag >> --query 'images[].imageManifest' --output text)
aws ecr put-image --repository-name << parameters.image_repo >> --image-tag << parameters.new_image_tag >> --image-manifest "$MANIFEST"
echo "added tag: << parameters.new_image_tag >> to image: << parameters.image_repo >>:<< parameters.new_image_tag >>"
jobs:
build:
parameters:
py_version:
type: string
default: latest
package_name:
type: string
docker:
- image: cimg/python:<< parameters.py_version >>
resource_class: large
steps:
- deci-common/checkout_and_skip_build:
check_version_file: true
- deci-common/get_persisted_version_info
- when:
condition:
and:
- not:
equal: [ develop, << pipeline.git.branch >> ]
- not:
equal: [ staging, << pipeline.git.branch >> ]
- not:
equal: [ master, << pipeline.git.branch >> ]
steps:
- run:
name: install Black Flake8 python linter
command: |
pip install --user -r requirements.dev.txt
- run:
name: Lint all python files changed since develop branch
command: |
flake8 --statistics --config scripts/flake8-config setup.py $(git diff --diff-filter ACM origin/master --name-only | grep 'py$' | grep -v 'experimental/' | grep -v 'experimental_models/')
- run:
name: Run Black on changed files against master branch
command: |
black --check setup.py $(git diff --diff-filter ACM origin/master --name-only | grep 'py$' | grep -v 'experimental/' | grep -v 'experimental_models/')
- run:
name: add requirements.txt and requirements.pro.txt to source code
command: |
cp requirements.txt src/super_gradients/requirements.txt
cp requirements.pro.txt src/super_gradients/requirements.pro.txt
- run:
name: install python dependencies
command: |
python3 -m venv venv
. venv/bin/activate
python3 -m pip install pip==22.0.4
cat requirements.txt | cut -f1 -d"#" | xargs -n 1 -L 1 pip install --progress-bar off
- run:
name: edit package version
command: |
echo "${NEW_VERSION}" > version.txt
cat version.txt
- run:
name: setup custom environment variables
command: |
echo 'export PYTHONPATH=/home/circleci/super_gradients' >> $BASH_ENV
echo 'export UPLOAD_LOGS=FALSE' >> $BASH_ENV
- run:
name: install package
no_output_timeout: 30m
command: |
. venv/bin/activate
python3 -m pip install --extra-index-url https://pypi.ngc.nvidia.com .[pro]
- run:
name: run tests with coverage
no_output_timeout: 30m
command: |
. venv/bin/activate
coverage run --source=super_gradients -m unittest tests/deci_core_unit_test_suite_runner.py
coverage report
coverage html # open htmlcov/index.html in a browser
- store_artifacts:
path: htmlcov
- store_artifacts:
path: ~/sg_logs
change_rc_to_b:
description: "change rc in the tag to b"
docker:
- image: cimg/base:stable-20.04
resource_class: small
steps:
- run:
name: change the rc to b
command:
|
BETA_TAG=$(echo ${CIRCLE_TAG} | sed -e 's|rc|b|'); echo ${BETA_TAG} >> ~/BETA_TAG
cat ~/BETA_TAG
- persist_to_workspace:
root: ~/
paths:
- "BETA_TAG"
build_and_publish_sg_container:
description : "building the temp image and pushing to dev ecr"
parameters:
repo_name:
type: string
default: 'deci/super-gradients'
sg_python_version:
type: string
default: $CIRCLE_TAG
docker:
- image: cimg/base:stable-20.04
resource_class: small
steps:
- checkout
- get_beta_and_rc_tags
- run:
command: echo *$BETA_TAG*
- setup_remote_docker:
version: << pipeline.parameters.remote_docker_version >>
docker_layer_caching: true
- deci-common/container_image_build:
dockerfile: scripts/Dockerfile
repository_name: << parameters.repo_name >>
image_tag: "$BETA_TAG"
build_args: 'SG_VERSION=<< parameters.sg_python_version >>'
extra_flags: ' --compress'
- deci-common/push_docker_image_aws_dev:
repository_name: << parameters.repo_name >>
image_tag: "$BETA_TAG"
additional_tags: "latest"
find_rc_tag_per_sha:
description: this command will take the sha of the last commit and find the rc tag it belongs to as ${RC_TAG} variale
docker:
- image: cimg/aws:2022.11.1
resource_class: small
steps:
- checkout
- run:
name: get rc tag of the final tag
command: |
RC_TAG=$(git tag --contains ${CIRCLE_SHA1} | grep -E '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+rc[[:digit:]]+' | head -n 1)
echo "Found RC version: ${RC_TAG}"
echo $RC_TAG >> ~/RC_TAG
- persist_to_workspace:
root: ~/
paths:
- "RC_TAG"
add_rc_tag_to_beta:
description: in the event of successful test promote beta to rc
parameters:
image_repo:
type: string
default: "deci/super-gradients"
docker:
- image: cimg/base:stable-20.04
resource_class: small
steps:
- get_beta_and_rc_tags
- run:
command: |
echo $BETA_TAG
- adding_tag_to_ecr_container_image:
image_repo: << parameters.image_repo >>
source_image_tag: $BETA_TAG
new_image_tag: $CIRCLE_TAG
add_release_tag_to_rc:
description: in the event of successful test promote rc to release and latest
parameters:
image_repo:
type: string
default: "deci/super-gradients"
docker:
- image: cimg/base:stable-20.04
resource_class: small
steps:
- get_beta_and_rc_tags
- run:
command: |
echo $RC_TAG
- adding_tag_to_ecr_container_image:
image_repo: << parameters.image_repo >>
source_image_tag: $RC_TAG
new_image_tag: ${CIRCLE_TAG}
testing_supergradients_docker_image:
description: "running integration test on the code"
parameters:
image_repo:
type: string
#reserved for testing when will be done
#machine: true
#resource_class: deci-ai/research-standard
docker:
- image: cimg/base:stable-20.04
steps:
- deci-common/ecr_login_dev
- get_beta_and_rc_tags
# - run:
# name: integration test
# #command: sudo docker run -it -e ENVIRONMENT_NAME=production -v ${PWD}:/SG -v /data:/data deciai/super-gradients:3.0.0 python3 ./tests/integration_tests/pretrained_models_test.py
# command: docker run --rm -it --shm-size=2gb --gpus all -v ${PWD}:/SG -v /data:/data << parameters.image_repo >>:<< parameters.image_tag >> python3 -c 'print("it works!")'
- run:
command: echo Hello world
release_candidate:
parameters:
py_version:
type: string
docker:
- image: cimg/python:<< parameters.py_version >>
steps:
- deci-common/checkout_and_skip_build:
check_version_file: true
- deci-common/get_persisted_version_info
- run:
name: edit package version
command: |
echo $NEW_VERSION > version.txt
- deci-common/pip_upload_package_codeartifact_dev:
codeartifact_repository: "deci-packages"
- deci-common/pip_test_package_installation_codeartifact_dev:
package_name: "super-gradients"
version: $NEW_VERSION
- deci-common/git_config_automation_user
- run:
name: "commit version file"
command: |
git commit version.txt -m "Deci Services - Changed version to $NEW_VERSION"
- deci-common/git_commit_and_tag:
version: $NEW_VERSION
release_version:
parameters:
py_version:
type: string
docker:
- image: cimg/python:<< parameters.py_version >>
steps:
- deci-common/checkout_and_skip_build:
check_version_file: true
- run:
name: verify __version__
command: python3 tests/verify_version.py $CIRCLE_TAG
- run:
name: add requirements.txt and requirements.pro.txt to source code
command: |
cp requirements.txt src/super_gradients/requirements.txt
cp requirements.pro.txt src/super_gradients/requirements.pro.txt
- run:
name: edit package version
command: |
echo $CIRCLE_TAG > version.txt
- deci-common/pip_upload_package_codeartifact_all_accounts:
codeartifact_repository: "deci-packages"
- deci-common/pip_test_package_installation_codeartifact_dev:
package_name: "super-gradients"
version: $CIRCLE_TAG
- deci-common/pip_test_package_installation_codeartifact_prod:
package_name: "super-gradients"
version: $CIRCLE_TAG
- deci-common/pip_upload_package_codeartifact_prod:
codeartifact_repository: "deci-toolkit"
- deci-common/git_commit_and_tag:
version: $CIRCLE_TAG
delete_remote_tag_before_tagging: true
- deci-common/tag_as:
tag_name: "stable"
delete_remote: true
- deci-common/github_create_release:
github_cli_token: $GITHUB_CLI_TOKEN
directory_to_cd_into: "."
tag: $CIRCLE_TAG
notes: "This GitHub Release was done automatically by CircleCI"
recipe_tests:
machine: true
resource_class: deci-ai/sg-gpu-on-premise
parameters:
sg_existing_env_path:
type: string
default: "/env/persistent_env"
sg_new_env_name:
type: string
default: "${CIRCLE_BUILD_NUM}"
sg_new_env_python_version:
type: string
default: "python3.8"
steps:
- checkout
- run:
name: install requirements and run recipe tests
command: |
<< parameters.sg_new_env_python_version >> -m venv << parameters.sg_new_env_name >>
source << parameters.sg_new_env_name >>/bin/activate
python3.8 -m pip install --upgrade setuptools pip wheel
python3.8 -m pip install -r requirements.txt
python3.8 -m pip install .
python3.8 -m pip install torch==1.12.0+cu116 torchvision==0.13.0+cu116 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu116
python3.8 src/super_gradients/examples/train_from_recipe_example/train_from_recipe.py --config-name=cifar10_resnet experiment_name=shortened_cifar10_resnet_accuracy_test training_hyperparams.max_epochs=100 training_hyperparams.average_best_models=False multi_gpu=DDP num_gpus=4
python3.8 src/super_gradients/examples/convert_recipe_example/convert_recipe_example.py --config-name=cifar10_conversion_params experiment_name=shortened_cifar10_resnet_accuracy_test
python3.8 src/super_gradients/examples/train_from_recipe_example/train_from_recipe.py --config-name=coco2017_yolox experiment_name=shortened_coco2017_yolox_n_map_test architecture=yolox_n training_hyperparams.loss=yolox_fast_loss training_hyperparams.max_epochs=10 training_hyperparams.average_best_models=False multi_gpu=DDP num_gpus=4
python3.8 src/super_gradients/examples/train_from_recipe_example/train_from_recipe.py --config-name=cityscapes_regseg48 experiment_name=shortened_cityscapes_regseg48_iou_test training_hyperparams.max_epochs=10 training_hyperparams.average_best_models=False multi_gpu=DDP num_gpus=4
coverage run --source=super_gradients -m unittest tests/deci_core_recipe_test_suite_runner.py
- run:
name: Remove new environment when failed
command: "rm -r << parameters.sg_new_env_name >>"
when: on_fail
workflows:
release:
jobs:
- deci-common/persist_version_info:
version_override: $CIRCLE_TAG
<<: *release_tag_filter
- deci-common/codeartifact_login:
name: "login_to_codeartifact_release"
repo_name: "deci-packages"
<<: *release_tag_filter
- build:
name: "build3.7"
py_version: "3.7"
package_name: "super-gradients"
requires:
- deci-common/persist_version_info
- login_to_codeartifact_release
<<: *release_tag_filter
- recipe_tests:
<<: *release_tag_filter
- release_version:
py_version: "3.7"
requires:
- "build3.7"
- recipe_tests
<<: *release_tag_filter
- deci-common/pip_upload_package_from_codeartifact_to_global_pypi:
package_name: "super-gradients"
name: "upload_super_gradients_to_pypi"
version: $CIRCLE_TAG
requires:
- "release_version"
context:
- pypi-public
<<: *release_tag_filter
build_and_deploy:
jobs:
- recipe_tests
SG_docker:
jobs:
- change_rc_to_b: # works on release candidate creation
<<: *release_candidate_tag_filter
- build_and_publish_sg_container: # works on release candidate creation
requires:
- "change_rc_to_b"
<<: *release_candidate_tag_filter
- testing_supergradients_docker_image: # works on release candidate creation
image_repo: '307629990626.dkr.ecr.us-east-1.amazonaws.com/deci/super-gradients'
requires:
- "build_and_publish_sg_container"
- "change_rc_to_b"
<<: *release_candidate_tag_filter
- add_rc_tag_to_beta: # works on release candidate creation for ECR Repo
requires:
- "testing_supergradients_docker_image"
- "change_rc_to_b"
<<: *release_candidate_tag_filter
- find_rc_tag_per_sha: # works on release
<<: *release_tag_filter
- add_release_tag_to_rc: # works on release
requires:
- "find_rc_tag_per_sha"
<<: *release_tag_filter
- slack/on-hold:
context: slack
channel: "sg-integration-tests"
requires:
- "add_release_tag_to_rc"
<<: *release_tag_filter
- hold-sg-public-release: # works on release
type: approval
requires:
- "slack/on-hold"
<<: *release_tag_filter
- docker/publish: # works on release
image: deciai/super-gradients
remote-docker-version: << pipeline.parameters.remote_docker_version >>
update-description: true
use-buildkit: true
use-remote-docker: true
use-docker-credentials-store: true
tag: latest,${CIRCLE_TAG}
extra_build_args: '--build-arg VERSION=${CIRCLE_TAG} --compress' #building from scratch as it faster and cheaper than download and retag
requires:
- "hold-sg-public-release"
<<: *release_tag_filter
- docker/publish: # works on release
image: deciai/super-gradients
remote-docker-version: << pipeline.parameters.remote_docker_version >>
update-description: true
use-buildkit: true
use-remote-docker: true
use-docker-credentials-store: true
tag: ${CIRCLE_TAG}-runtime
extra_build_args: '--build-arg VERSION=${CIRCLE_TAG} --build-arg DOCKER_IMAGE_TAG=11.3.1-runtime-ubuntu20.04 --compress'
requires:
- "hold-sg-public-release"
<<: *release_tag_filter
Tip!
Press p or to see the previous file or,
n or to see the next file