forked from OpenMined/PySyft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
978 lines (853 loc) · 34.9 KB
/
tox.ini
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
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
[tox]
envlist =
hagrid.publish
lint
stack.test.integration
syft.docs
syft.jupyter
syft.publish
syft.test.security
syft.test.unit
syft.test.notebook
stack.test.notebook
stack.test.integration.enclave.oblv
stack.test.integration.k8s
stack.test.vm
stack.test.podman
frontend.test.unit
frontend.test.e2e
frontend.generate.types
syft.build.helm
syft.package.helm
syft.test.helm
syft.protocol.check
syftcli.test.unit
syftcli.publish
syftcli.build
skipsdist = True
[testenv]
basepython = python3
install_command = pip install {opts} {packages}
commands =
python --version
# Syft
[testenv:syft]
deps =
-e{toxinidir}/packages/syft[dev]
changedir = {toxinidir}/packages/syft
description = Syft
commands =
pip list
[testenv:hagrid]
deps =
-e{toxinidir}/packages/hagrid[dev]
changedir = {toxinidir}/packages/hagrid
description = Syft
commands =
pip list
[testenv:syftcli]
deps =
-e{toxinidir}/packages/syftcli[dev]
changedir = {toxinidir}/packages/syftcli
description = Syft CLI
install_command = pip install {opts} {packages}
commands =
pip list
[testenv:hagrid.publish]
changedir = {toxinidir}/packages/hagrid
description = Build and Publish Hagrid Wheel
commands =
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine tox build
python -c 'from shutil import rmtree; rmtree("build", True); rmtree("dist", True)'
python -m build .
[testenv:syftcli.publish]
changedir = {toxinidir}/packages/syftcli
description = Build and Publish Syft CLI Wheel
allowlist_externals =
bash
commands =
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine tox build
bash -c 'rm -rf build/ dist/ syftcli.egg-info/'
python -m build .
[testenv:syftcli.build]
basepython = python3
changedir = {toxinidir}/packages/syftcli
description = Build SyftCLI Binary for each platform
allowlist_externals =
bash
setenv =
SYFT_CLI_VERSION = {env:SYFT_CLI_VERSION}
commands =
python -m pip install --upgrade pip
pip install -e ".[build]"
python -c 'from shutil import rmtree; rmtree("build", True); rmtree("dist", True)'
;Since we build universal binary for MacOS,we need to check the python is universal2 or not
bash -c 'if [[ "$OSTYPE" == "darwin"* ]]; then \
arch_info=$(lipo -info "$(which python3)"); \
echo "Arch: $arch_info"; \
if [[ "$arch_info" == *"Non-fat"* ]]; then \
echo "Building on MacOS Requires Universal2 python"; \
echo "Please install universal2 python from https://www.python.org/downloads/macos/"; \
exit 1; \
fi; \
fi'
;check the platform and build accordingly by naming the binary as syftcli plus the extension
; Check if SYFT_CLI_VERSION is set or choosing the current version available
bash -c 'if [ -z $SYFT_CLI_VERSION ]; then \
echo "SYFT_CLI_VERSION is not set"; \
SYFT_CLI_VERSION=$(python3 syftcli/version.py); \
echo "Setting SYFT_CLI_VERSION to $SYFT_CLI_VERSION"; \
else \
echo "SYFT_CLI_VERSION is already set to $SYFT_CLI_VERSION"; \
fi && \
echo "Building syftcli-$SYFT_CLI_VERSION for $OSTYPE" && \
if [[ "$OSTYPE" == "darwin"* ]]; then \
pyinstaller --clean --onefile --name syftcli-v$SYFT_CLI_VERSION-macos-universal2 --distpath ./dist/cli syftcli/cli.py --target-arch universal2; \
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then \
pyinstaller --clean --onefile --name syftcli-v$SYFT_CLI_VERSION-linux-x86_64 --distpath ./dist/cli syftcli/cli.py; \
else \
pyinstaller --clean --onefile --name syftcli-v$SYFT_CLI_VERSION-windows-x86_64 --distpath ./dist/cli syftcli/cli.py; \
fi'
[testenv:lint]
description = Linting
allowlist_externals =
bash
deps =
black[python2]
isort
pre-commit
commands =
black .
isort .
pre-commit run --all-files
[testenv:frontend.test.unit]
description = Frontend Unit Tests
deps =
{[testenv:hagrid]deps}
allowlist_externals =
docker
bash
pnpm
passenv=HOME, USER
changedir = {toxinidir}/packages/grid/frontend
setenv =
DOCKER = {env:DOCKER:false}
commands =
bash -c "echo Running with DOCKER=$DOCKER; date"
bash -c 'if [[ "$DOCKER" == "false" ]]; then \
bash ./scripts/check_pnpm.sh; \
pnpm install; \
pnpm run test:unit; \
else \
docker build --target grid-ui-tests -t ui-test -f frontend.dockerfile .; \
docker run -t ui-test; \
fi'
[testenv:frontend.test.e2e]
description = Frontend Unit Tests
deps =
{[testenv:hagrid]deps}
allowlist_externals =
docker
bash
pnpm
sleep
passenv=HOME, USER
changedir = {toxinidir}/packages/grid/frontend
setenv =
HAGRID_FLAGS = {env:HAGRID_FLAGS:--tag=local --test}
ENABLE_SIGNUP=True
commands =
bash ./scripts/check_pnpm.sh
bash -c "echo Running with HAGRID_FLAGS=$HAGRID_FLAGS; date"
; install hagrid
bash -c 'if [[ "$HAGRID_FLAGS" == *"local"* ]]; then \
pip install -e ../../hagrid; \
else \
pip install --force hagrid; \
fi'
; fix windows encoding
- chcp 65001
; check docker versions
bash -c "docker --version"
bash -c "docker compose version"
; reset volumes and create nodes
bash -c "echo Starting Nodes; date"
bash -c "docker rm -f $(docker ps -a -q) || true"
bash -c "docker volume rm test-domain-1_mongo-data --force || true"
bash -c "docker volume rm test-domain-1_credentials-data --force || true"
bash -c "docker volume rm test-domain-1_seaweedfs-data --force || true"
bash -c 'HAGRID_ART=$HAGRID_ART hagrid launch test_domain_1 domain to docker:9081 $HAGRID_FLAGS --enable-signup --no-health-checks --verbose --no-warnings'
bash -c '(docker logs test_domain_1-frontend-1 -f &) | grep -q -E "Network:\s+https?://[a-zA-Z0-9.-]+:[0-9]+/" || true'
bash -c '(docker logs test_domain_1-backend-1 -f &) | grep -q "Application startup complete" || true'
pnpm install
pnpm dlx [email protected] install --with-deps
pnpm test:e2e
; shutdown
bash -c "echo Killing Nodes; date"
bash -c 'HAGRID_ART=false hagrid land all --force'
[testenv:stack.test.integration]
description = Integration Tests for Core Stack
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
changedir = {toxinidir}
allowlist_externals =
docker
grep
sleep
bash
chcp
passenv=HOME, USER
setenv =
HAGRID_FLAGS = {env:HAGRID_FLAGS:--tag=local --test}
EMULATION = {env:EMULATION:false}
HAGRID_ART = false
PYTHONIOENCODING = utf-8
PYTEST_MODULES = {env:PYTEST_MODULES:frontend network e2e security redis}
commands =
bash -c "echo Running with HAGRID_FLAGS=$HAGRID_FLAGS EMULATION=$EMULATION PYTEST_MODULES=$PYTEST_MODULES; date"
; install syft and hagrid
bash -c 'if [[ "$HAGRID_FLAGS" == *"latest"* ]]; then \
pip install --force pytest hagrid syft; \
elif [[ "$HAGRID_FLAGS" == *"beta"* ]]; then \
pip install --force pytest hagrid; \
pip install --force -U --pre syft; \
else \
pip install -e packages/hagrid -e packages/syft[dev]; \
fi'
; fix windows encoding
- chcp 65001
; check docker versions
bash -c "docker --version"
bash -c "docker compose version"
; reset volumes and create nodes
bash -c "echo Starting Nodes; date"
bash -c "docker rm -f $(docker ps -a -q) || true"
bash -c "docker volume rm test-domain-1_mongo-data --force || true"
bash -c "docker volume rm test-domain-1_credentials-data --force || true"
bash -c "docker volume rm test-domain-1_seaweedfs-data --force || true"
bash -c "docker volume rm test-domain-1_tailscale-data --force || true"
; bash -c "docker volume rm test-domain-2_mongo-data --force || true"
; bash -c "docker volume rm test-domain-2_credentials-data --force || true"
; bash -c "docker volume rm test-domain-2_seaweedfs-data --force || true"
; bash -c "docker volume rm test-domain-2_tailscale-data --force || true"
bash -c "docker volume rm test-gateway-1_mongo-data --force || true"
bash -c "docker volume rm test-gateway-1_credentials-data --force || true"
bash -c "docker volume rm test-gateway-1_seaweedfs-data --force || true"
bash -c "docker volume rm test-gateway-1_tailscale-data --force || true"
bash -c "docker volume rm test-gateway-1_headscale-data --force || true"
python -c 'import syft as sy; sy.stage_protocol_changes()'
bash -c 'HAGRID_ART=$HAGRID_ART hagrid launch test-gateway-1 network to docker:9081 $HAGRID_FLAGS --no-health-checks --verbose --no-warnings --dev'
bash -c 'HAGRID_ART=$HAGRID_ART hagrid launch test-domain-1 domain to docker:9082 $HAGRID_FLAGS --no-health-checks --enable-signup --verbose --no-warnings --dev'
; bash -c 'HAGRID_ART=$HAGRID_ART hagrid launch test-domain-2 domain to docker:9083 --headless $HAGRID_FLAGS --enable-signup --no-health-checks --verbose --no-warnings --dev'
; wait for nodes to start
docker ps
bash -c "echo Waiting for Nodes; date"
bash -c '(docker logs test-domain-1-frontend-1 -f &) | grep -q -E "Network:\s+https?://[a-zA-Z0-9.-]+:[0-9]+/" || true'
bash -c '(docker logs test-domain-1-backend-1 -f &) | grep -q "Application startup complete" || true'
; bash -c '(docker logs test_domain_2-backend-1 -f &) | grep -q "Application startup complete" || true'
bash -c '(docker logs test-gateway-1-backend-1 -f &) | grep -q "Application startup complete" || true'
; frontend
bash -c 'if [[ "$PYTEST_MODULES" == *"frontend"* ]]; then \
echo "Starting frontend"; date; \
pytest tests/integration -m frontend -p no:randomly --co; \
pytest tests/integration -m frontend -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no; \
return=$?; \
docker stop test_domain_1-frontend-1 || true; \
echo "Finished frontend"; date; \
exit $return; \
fi'
; network
bash -c 'if [[ "$PYTEST_MODULES" == *"network"* ]]; then \
echo "Starting network"; date; \
pytest tests/integration -m network -p no:randomly --co; \
pytest tests/integration -m network -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no; \
return=$?; \
echo "Finished network"; date; \
exit $return; \
fi'
; shutdown
bash -c "echo Killing Nodes; date"
bash -c 'HAGRID_ART=false hagrid land all --force'
[testenv:syft.docs]
description = Build Docs for Syft
changedir = {toxinidir}/docs
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
-r {toxinidir}/docs/requirements.txt
allowlist_externals =
make
echo
cd
rm
ls
xargs
bash
commands =
python --version
bash -c "cd source/api_reference && ls | grep -v index.rst | xargs rm"
sphinx-apidoc -f -M -d 2 -o ./source/api_reference/ ../packages/syft/src/syft
make html
echo "Open: {toxinidir}/docs/build/html/index.html"
[testenv:syft.jupyter]
description = Jupyter Notebook with Editable Syft
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
jupyter
jupyterlab
commands =
pip install -e packages/hagrid
pip install jupyter jupyterlab --upgrade
jupyter lab --ip 0.0.0.0 --ServerApp.token={posargs}
[testenv:syft.protocol.check]
description = Syft Protocol Check
deps =
{[testenv:syft]deps}
changedir = {toxinidir}/packages/syft
allowlist_externals =
bash
setenv =
BUMP = {env:BUMP:False}
commands =
bash -c "echo Using BUMP=${BUMP}"
python -c 'import syft as sy; sy.check_or_stage_protocol()'
bash -c 'if [[ "$BUMP" != "False" ]]; then \
python -c "import syft as sy; sy.bump_protocol_version()"; \
fi'
[testenv:syft.publish]
changedir = {toxinidir}/packages/syft
description = Build and Publish Syft Wheel
commands =
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine tox build
python -c 'from shutil import rmtree; rmtree("build", True); rmtree("dist", True)'
python -m build .
[testenv:syft.test.security]
description = Security Checks for Syft
changedir = {toxinidir}/packages/syft
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
commands =
pip install --upgrade pip
bandit -r src
# ansible 8.4.0
# restrictedpython 6.2
safety check -i 60840 -i 54229 -i 54230 -i 42923
[testenv:syft.test.unit]
description = Syft Unit Tests
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
changedir = {toxinidir}/packages/syft
setenv =
ENABLE_SIGNUP=False
commands =
pip list
pytest -n auto
[testenv:stack.test.integration.enclave.oblv]
description = Integration Tests for Oblv Enclave
changedir = {toxinidir}
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
allowlist_externals =
grep
bash
passenv=HOME, USER
setenv =
LOCAL_ENCLAVE_PORT=8010
ENABLE_OBLV=true
DOMAIN_CONNECTION_PORT=8010
ENABLE_SIGNUP=True
commands =
pip install oblv-ctl==0.3.1
# run at start to kill any process started beforehand
bash -c 'chmod +x scripts/kill_process_in_port.sh && ./scripts/kill_process_in_port.sh $LOCAL_ENCLAVE_PORT'
bash -c 'rm -rf ~/.syft/syft-enclave'
bash -c 'git clone https://github.com/OpenMined/syft-enclave.git ~/.syft/syft-enclave || true'
bash -c 'cd ~/.syft/syft-enclave && git fetch && git checkout dev && git pull && pip install -r requirements_test.txt || true'
# Starting FastAPI server locally
bash -c 'cd ~/.syft/syft-enclave/src && uvicorn app:app --host 0.0.0.0 --port $LOCAL_ENCLAVE_PORT > /dev/null 2>&1 &'
bash -c 'cd tests/integration/external/oblv && pytest -p no:randomly -vvvv'
bash -c 'chmod +x scripts/kill_process_in_port.sh && ./scripts/kill_process_in_port.sh $LOCAL_ENCLAVE_PORT'
[testenv:syft.test.notebook]
description = Syft Notebook Tests
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
nbmake
changedir = {toxinidir}/notebooks
allowlist_externals =
bash
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:python}
DEV_MODE = {env:DEV_MODE:True}
TEST_NOTEBOOK_PATHS = {env:TEST_NOTEBOOK_PATHS:api/0.8,tutorials}
ENABLE_SIGNUP=True
commands =
bash -c "echo Running with ORCHESTRA_DEPLOYMENT_TYPE=$ORCHESTRA_DEPLOYMENT_TYPE DEV_MODE=$DEV_MODE TEST_NOTEBOOK_PATHS=$TEST_NOTEBOOK_PATHS; date"
bash -c "for subfolder in $(echo ${TEST_NOTEBOOK_PATHS} | tr ',' ' '); do \
if [[ $subfolder == *tutorials* ]]; then \
pytest --nbmake "$subfolder" -p no:randomly --ignore=tutorials/model-training -n $(python -c 'import multiprocessing; print(multiprocessing.cpu_count())') -vvvv && \
pytest --nbmake tutorials/model-training -p no:randomly -vvvv; \
else \
pytest --nbmake "$subfolder" -p no:randomly -vvvv; \
fi \
done"
; pytest --nbmake api/0.8 -p no:randomly -vvvv
; pytest --nbmake api/0.9 -p no:randomly -vvvv
; pytest --nbmake tutorials -p no:randomly -vvvv
; pytest --nbmake tutorials/pandas-cookbook -p no:randomly -vvvv
[testenv:stack.test.notebook]
description = Stack Notebook Tests
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
nbmake
changedir = {toxinidir}/notebooks
allowlist_externals =
bash
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:single_container}
DEV_MODE = {env:DEV_MODE:True}
TEST_NOTEBOOK_PATHS = {env:TEST_NOTEBOOK_PATHS:api/0.8,tutorials}
ENABLE_SIGNUP=True
commands =
# Volume cleanup
bash -c "docker volume rm test-domain-1_mongo-data --force || true"
bash -c "docker volume rm test-domain-1_credentials-data --force || true"
bash -c "docker volume rm test-domain-1_seaweedfs-data --force || true"
bash -c "echo Running with ORCHESTRA_DEPLOYMENT_TYPE=$ORCHESTRA_DEPLOYMENT_TYPE DEV_MODE=$DEV_MODE TEST_NOTEBOOK_PATHS=$TEST_NOTEBOOK_PATHS; date"
bash -c "for subfolder in $(echo ${TEST_NOTEBOOK_PATHS} | tr ',' ' ');\
do \
pytest --nbmake "$subfolder" -p no:randomly -vvvv --nbmake-timeout=1000;\
done"
; pytest --nbmake api/0.8 -p no:randomly -vvvv
; pytest --nbmake api/0.9 -p no:randomly -vvvv
; pytest --nbmake tutorials -p no:randomly -vvvv
; pytest --nbmake tutorials/pandas-cookbook -p no:randomly -vvvv
[testenv:stack.test.vm]
description = Stack VM Tests
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
nbmake
allowlist_externals =
cd
vagrant
bash
changedir = {toxinidir}
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:vm}
VAGRANT_DESTROY = {env:VAGRANT_DESTROY:skip}
commands =
bash -c 'if [[ "$(uname -m)" == *"arm"* ]]; then \
export VAGRANT_BOX="ubuntu-22-04-arm64"; \
elif [[ "$(uname -m)" == *"x86"* ]]; then \
export VAGRANT_BOX="ubuntu-22-04-x86"; \
else \
echo "Unsupported architecture."; \
fi; \
echo $VAGRANT_BOX; \
cd packages/grid; \
if [[ "$VAGRANT_DESTROY" == *"true"* ]]; then \
vagrant destroy $VAGRANT_BOX --force || true; \
else \
vagrant ssh $VAGRANT_BOX -c "docker ps -aq | xargs -I {:} docker rm {:} --force"; \
vagrant ssh $VAGRANT_BOX -c "docker volume prune --filter all=1 --force || true"; \
fi; \
vagrant up $VAGRANT_BOX --provision; \
'
pytest --nbmake notebooks/api/0.8 -p no:randomly -vvvv
; pytest --nbmake notebooks/api/0.9 -p no:randomly -vvvv
bash -c 'if [[ "$(uname -m)" == *"arm"* ]]; then \
export VAGRANT_BOX="ubuntu-22-04-arm64"; \
elif [[ "$(uname -m)" == *"x86"* ]]; then \
export VAGRANT_BOX="ubuntu-22-04-x86"; \
else \
echo "Unsupported architecture."; \
fi; \
echo $VAGRANT_BOX; \
cd packages/grid; \
if [[ "$VAGRANT_DESTROY" == *"true"* ]]; then \
vagrant destroy $VAGRANT_BOX --force || true; \
fi; \
'
[testenv:stack.test.podman]
description = Stack podman Tests for Rhel & Centos
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
nbmake
allowlist_externals =
cd
vagrant
bash
changedir = {toxinidir}
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:podman}
NODE_PORT = {env:NODE_PORT:8080}
commands =
python -c 'import syft as sy; sy.stage_protocol_changes()'
bash -c "podman pod rm --force --all || true";
bash -c "podman system prune --volumes --force || true";
bash -c "podman volume rm $(podman volume ls -q)||true";
# Force Removal of images
bash -c "podman image prune --all --force || true";
# Build Backend Image
bash -c "SYFT_VERSION=$(python packages/grid/VERSION) && podman build -t docker.io/openmined/grid-backend:$SYFT_VERSION -f packages/grid/backend/backend.dockerfile --target backend packages";
# Build Frontend Image
bash -c "SYFT_VERSION=$(python packages/grid/VERSION) && podman build -t docker.io/openmined/grid-frontend:$SYFT_VERSION -f packages/grid/frontend/frontend.dockerfile --target grid-ui-development packages/grid/frontend";
bash -c 'cd packages/grid/podman/podman-kube && podman play kube podman-syft-kube.yaml --configmap=podman-syft-kube-config.yaml'
bash -c '(podman logs -f syft-backend &) | grep -q "Application startup complete" || true'
pytest --nbmake notebooks/api/0.8 -p no:randomly -vvvv
[testenv:frontend.generate.types]
description = Generate Types for Frontend
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
allowlist_externals =
cd
bash
pnpm
changedir = {toxinidir}/packages/grid/frontend
passenv =
PNPM_HOME
commands =
bash -c ./scripts/check_pnpm.sh
pnpm add -g json-schema-to-typescript
; clear the old ones
bash -c 'rm -rf ./schema'
bash -c 'rm -rf ./src/types/generated'
; generate new ones
bash -c 'python3 -c "import syft as sy;sy.util.schema.generate_json_schemas()"'
bash -c "json2ts -i './schema/**/*.json' -o ./src/types/generated"
bash -c "python3 ./scripts/replace_imports.py ./src/types/generated"
[mypy]
python_version = 3.11
disable_error_code = attr-defined, valid-type, no-untyped-call, arg-type
[testenv:stack.test.integration.k8s]
description = Integration Tests for Core Stack
basepython = python3
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
nbmake
changedir = {toxinidir}
passenv=HOME, USER
allowlist_externals =
devspace
kubectl
grep
sleep
bash
kubectx
k3d
echo
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:k8s}
NODE_PORT = {env:NODE_PORT:9082}
commands =
python -c 'import syft as sy; sy.stage_protocol_changes()'
k3d version
# bash -c "docker rm $(docker ps -aq) --force || true"
# Deleting current cluster
bash -c "k3d cluster delete test-gateway-1 || true"
bash -c "k3d cluster delete test-domain-1 || true"
# bash -c "k3d cluster delete test-domain-2 || true"
# Deleting registery & volumes
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c "docker volume rm k3d-test-gateway-1-images --force || true"
bash -c "docker volume rm k3d-test-domain-1-images --force || true"
# bash -c "docker volume rm k3d-test-domain-2-images --force || true"
# Creating registory
bash -c 'k3d registry create registry.localhost --port 12345 -v `pwd`/k3d-registry:/var/lib/registry || true'
# Creating test-gateway-1 cluster on port 9081
bash -c 'NODE_NAME=test-gateway-1 NODE_PORT=9081 && \
k3d cluster create $NODE_NAME -p "$NODE_PORT:80@loadbalancer" --registry-use k3d-registry.localhost || true \
k3d cluster start $NODE_NAME'
bash -c 'NODE_NAME=test-gateway-1 NODE_PORT=9081 && \
cd packages/grid && \
(r=5;while ! \
devspace --no-warn --kube-context "k3d-$NODE_NAME" --namespace $NODE_NAME \
-p gateway \
--var NODE_NAME=$NODE_NAME \
--var NETWORK_CHECK_INTERVAL=5 \
--var ASSOCIATION_TIMEOUT=100 \
--var TEST_MODE=1 \
--var CONTAINER_REGISTRY=k3d-registry.localhost:12345 \
--var NODE_TYPE=gateway \
deploy -b; \
do ((--r))||exit;echo "retrying" && sleep 20;done)'
# Creating test-domain-1 cluster on port 9082
bash -c 'NODE_NAME=test-domain-1 NODE_PORT=9082 && \
k3d cluster create $NODE_NAME -p "$NODE_PORT:80@loadbalancer" --registry-use k3d-registry.localhost || true \
k3d cluster start $NODE_NAME'
bash -c 'NODE_NAME=test-domain-1 NODE_PORT=9082 && \
cd packages/grid && \
(r=5;while ! \
devspace --no-warn --kube-context "k3d-$NODE_NAME" --namespace $NODE_NAME \
--var NODE_NAME=$NODE_NAME \
--var DOMAIN_CHECK_INTERVAL=5 \
--var ASSOCIATION_TIMEOUT=100 \
--var TEST_MODE=1 \
--var CONTAINER_REGISTRY=k3d-registry.localhost:12345 \
deploy -b; \
do ((--r))||exit;echo "retrying" && sleep 20;done)'
# bash -c 'NODE_NAME=test-domain-2 NODE_PORT=9083 && \
# k3d cluster create $NODE_NAME -p "$NODE_PORT:80@loadbalancer" --registry-use k3d-registry.localhost || true \
# k3d cluster start $NODE_NAME'
# bash -c 'NODE_NAME=test-domain-2 NODE_PORT=9083 && \
# cd packages/grid && \
# (r=5;while ! \
# devspace --no-warn --kube-context "k3d-$NODE_NAME" --namespace $NODE_NAME \
# --var DOMAIN_NAME=$NODE_NAME \
# --var DOMAIN_CHECK_INTERVAL=5 \
# --var ASSOCIATION_TIMEOUT=100 \
# --var TEST_MODE=1 \
# --var CONTAINER_REGISTRY=k3d-registry.localhost:12345 \
# deploy -b -p domain; \
# do ((--r))||exit;echo "retrying" && sleep 20;done)'
sleep 30
# wait for front end
bash packages/grid/scripts/wait_for.sh service frontend --context k3d-test-domain-1 --namespace test-domain-1
bash -c '(kubectl logs service/frontend --context k3d-test-domain-1 --namespace test-domain-1 -f &) | grep -q -E "Network:\s+https?://[a-zA-Z0-9.-]+:[0-9]+/" || true'
# wait for test gateway 1
bash packages/grid/scripts/wait_for.sh service mongo --context k3d-test-gateway-1 --namespace test-gateway-1
bash packages/grid/scripts/wait_for.sh service backend --context k3d-test-gateway-1 --namespace test-gateway-1
bash packages/grid/scripts/wait_for.sh service proxy --context k3d-test-gateway-1 --namespace test-gateway-1
# bash packages/grid/scripts/wait_for.sh service queue --context k3d-test-gateway-1 --namespace test-gateway-1
# bash packages/grid/scripts/wait_for.sh service redis --context k3d-test-gateway-1 --namespace test-gateway-1
# bash packages/grid/scripts/wait_for.sh service backend-stream --context k3d-test-gateway-1 --namespace test-gateway-1
# bash packages/grid/scripts/wait_for.sh service headscale --context k3d-test-gateway-1 --namespace test-gateway-1
# wait for test domain 1
bash packages/grid/scripts/wait_for.sh service mongo --context k3d-test-domain-1 --namespace test-domain-1
bash packages/grid/scripts/wait_for.sh service backend --context k3d-test-domain-1 --namespace test-domain-1
bash packages/grid/scripts/wait_for.sh service proxy --context k3d-test-domain-1 --namespace test-domain-1
# bash packages/grid/scripts/wait_for.sh service frontend --context k3d-test-domain-1 --namespace test-domain-1
# bash packages/grid/scripts/wait_for.sh service proxy --context k3d-test-domain-1 --namespace test-domain-1
# bash packages/grid/scripts/wait_for.sh service queue --context k3d-test-domain-1 --namespace test-domain-1
# bash packages/grid/scripts/wait_for.sh service redis --context k3d-test-domain-1 --namespace test-domain-1
# bash packages/grid/scripts/wait_for.sh service backend-stream --context k3d-test-domain-1 --namespace test-domain-1
# bash packages/grid/scripts/wait_for.sh service seaweedfs --context k3d-test-domain-1 --namespace test-domain-1
# wait for test domain 2
# bash packages/grid/scripts/wait_for.sh service frontend --context k3d-test-domain-2 --namespace test-domain-2
# bash packages/grid/scripts/wait_for.sh service proxy --context k3d-test-domain-2 --namespace test-domain-2
# bash packages/grid/scripts/wait_for.sh service queue --context k3d-test-domain-2 --namespace test-domain-2
# bash packages/grid/scripts/wait_for.sh service redis --context k3d-test-domain-2 --namespace test-domain-2
# bash packages/grid/scripts/wait_for.sh service db --context k3d-test-domain-2 --namespace test-domain-2
# bash packages/grid/scripts/wait_for.sh service backend --context k3d-test-domain-2 --namespace test-domain-2
# bash packages/grid/scripts/wait_for.sh service backend-stream --context k3d-test-domain-2 --namespace test-domain-2
# bash packages/grid/scripts/wait_for.sh service seaweedfs --context k3d-test-domain-2 --namespace test-domain-2
# pytest tests/integration -m frontend -p no:randomly --co
# bash -c "CONTAINER_HOST=$CONTAINER_HOST pytest tests/integration -m frontend -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no"
# Checking logs generated & startup of test-domain 1
bash -c '(kubectl logs service/backend --context k3d-test-domain-1 --namespace test-domain-1 -f &) | grep -q "Application startup complete" || true'
# Checking logs generated & startup of test-gateway-1
bash -c '(kubectl logs service/backend --context k3d-test-gateway-1 --namespace test-gateway-1 -f &) | grep -q "Application startup complete" || true'
# frontend
bash -c 'if [[ "$PYTEST_MODULES" == *"frontend"* ]]; then \
echo "Starting frontend"; date; \
pytest tests/integration -m frontend -p no:randomly -k "test_serves_domain_frontend" --co; \
pytest tests/integration -m frontend -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no -k "test_serves_domain_frontend"; \
return=$?; \
echo "Finished frontend"; date; \
exit $return; \
fi'
# ignore 06 because of opendp on arm64
# Run 0.8 notebooks
pytest --nbmake notebooks/api/0.8 -p no:randomly -vvvv -k 'not 06'
#Integration + Gateway Connection Tests
pytest tests/integration/network -p no:randomly -vvvv
# deleting clusters created
bash -c "k3d cluster delete test-gateway-1 || true"
bash -c "k3d cluster delete test-domain-1 || true"
# bash -c "k3d cluster delete test-domain-2 || true"
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c "docker rm $(docker ps -aq) --force || true"
bash -c "docker volume rm k3d-test-gateway-1-images --force || true"
bash -c "docker volume rm k3d-test-domain-1-images --force || true"
# bash -c "docker volume rm k3d-test-domain-2-images --force || true"
[testenv:syft.build.helm]
description = Build Helm Chart for Kubernetes
deps =
pyyaml
changedir = {toxinidir}
passenv=HOME, USER, CONTAINER_REGISTRY , VERSION
allowlist_externals =
devspace
kubectl
grep
sleep
bash
kubectx
k3d
echo
rm
helm
commands =
k3d version
devspace version
bash -c "k3d cluster delete build ; \
docker volume rm k3d-build-images --force || true"
bash -c 'k3d cluster create build && \
k3d cluster start build && \
echo "Waiting for cluster to be ready..." && \
sleep 20'
bash -c 'cd packages/grid && \
[[ -n "$CONTAINER_REGISTRY" ]] && REGISTRY_FLAG="--var CONTAINER_REGISTRY=$CONTAINER_REGISTRY" || REGISTRY_FLAG="" && \
[[ -n "$VERSION" ]] && VERSION_FLAG="--var VERSION=$VERSION" || VERSION_FLAG="" && \
devspace deploy --render --skip-build ${REGISTRY_FLAG} ${VERSION_FLAG} --kube-context "k3d-build" --no-warn --no-colors > out.txt ; \
EXITCODE=$?; OUTPUT=$(cat out.txt); printf "Devspace exit code: $EXITCODE\nDevspace output:\n$OUTPUT\n"; exit $EXITCODE'
bash -c 'cd packages/grid && \
python3 helm/helm.py out.txt && \
rm out.txt'
bash -c 'cd packages/grid/helm && \
helm lint syft'
bash -c "k3d cluster delete build || true"
[testenv:syft.package.helm]
description = Package Helm Chart for Kubernetes
deps =
changedir = {toxinidir}
passenv=HOME, USER
allowlist_externals =
devspace
kubectl
grep
sleep
bash
kubectx
k3d
echo
rm
helm
commands =
bash -c 'cd packages/grid/helm && \
helm lint syft'
bash -c 'cd packages/grid/helm/syft && \
helm dependency update'
bash -c 'cd packages/grid/helm && \
helm package syft --destination repo'
bash -c 'cd packages/grid/helm/repo && \
helm repo index . --url https://openmined.github.io/PySyft/helm'
[testenv:syft.test.helm]
description = Test Helm Chart for Kubernetes
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
nbmake
changedir = {toxinidir}
passenv=HOME, USER
allowlist_externals =
devspace
kubectl
grep
sleep
bash
kubectx
k3d
echo
rm
helm
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:k8s}
NODE_PORT = {env:NODE_PORT:8080}
commands =
k3d version
; bash -c "docker rm $(docker ps -aq) --force || true"
bash -c "k3d cluster delete syft || true"
bash -c "docker volume rm k3d-syft-images --force || true"
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c 'k3d registry create registry.localhost --port 12345 -v `pwd`/k3d-registry:/var/lib/registry || true'
bash -c 'NODE_NAME=syft NODE_PORT=8080 && \
k3d cluster create syft -p "$NODE_PORT:80@loadbalancer" --registry-use k3d-registry.localhost || true \
k3d cluster start syft'
; skopeo list-tags --tls-verify=false docker://k3d-registry.localhost:12345/openmined/grid-backend
; skopeo inspect --tls-verify=false docker://k3d-registry.localhost:12345/openmined/grid-backend:f1725f
; helm uninstall --kube-context k3d-syft --namespace syft syft
; helm install --kube-context k3d-syft --namespace syft syft ./syft
; k3d cluster create syft -p "8080:80@loadbalancer" && k3d cluster start syft
sleep 50
bash -c 'cd packages/grid && \
kubectl --context k3d-syft create namespace syft || true; \
helm install --kube-context k3d-syft --namespace syft syft ./helm/syft --debug'
bash packages/grid/scripts/wait_for.sh service frontend --context k3d-syft --namespace syft
bash -c '(kubectl logs service/frontend --context k3d-syft --namespace syft -f &) | grep -q -E "Network:\s+https?://[a-zA-Z0-9.-]+:[0-9]+/" || true'
; wait for everything else to be loaded
bash packages/grid/scripts/wait_for.sh service mongo --context k3d-syft --namespace syft
bash packages/grid/scripts/wait_for.sh service backend --context k3d-syft --namespace syft
bash packages/grid/scripts/wait_for.sh service proxy --context k3d-syft --namespace syft
bash -c '(kubectl logs service/backend --context k3d-syft --namespace syft -f &) | grep -q "Application startup complete" || true'
; frontend
bash -c 'if [[ "$PYTEST_MODULES" == *"frontend"* ]]; then \
echo "Starting frontend"; date; \
pytest tests/integration -m frontend -p no:randomly -k "test_serves_domain_frontend" --co; \
pytest tests/integration -m frontend -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no -k "test_serves_domain_frontend"; \
return=$?; \
echo "Finished frontend"; date; \
exit $return; \
fi'
; ignore 06 because of opendp on arm64
pytest --nbmake notebooks/api/0.8 -p no:randomly -vvvv -k 'not 06'
bash -c "k3d cluster delete syft || true"
bash -c "docker volume rm k3d-syft-images --force || true"
[testenv:syftcli.test.unit]
description = Syft CLI Unit Tests
deps =
{[testenv:syftcli]deps}
changedir = {toxinidir}/packages/syftcli
commands =
pip list
pytest
[testenv:dev.k8s.registry]
changedir = {toxinidir}/packages/grid
passenv=HOME,USER
allowlist_externals =
bash
commands =
bash -c 'k3d registry create registry.localhost --port 12345 -v $HOME/.k3d-registry:/var/lib/registry'
bash -c '\
CYAN="\033[1;36m"; \
CLEAR="\033[0m"; \
printf "\n${CYAN}---------------------------------------------------------\n" ;\
printf "Make sure to add the following to your /etc/hosts file:${CLEAR}\n";\
printf "127.0.0.1 k3d-registry.localhost\n";\
printf "${CYAN}---------------------------------------------------------${CLEAR}\n"'
[testenv:dev.k8s.start]
changedir = {toxinidir}/packages/grid
allowlist_externals =
bash
k3d
commands =
bash -c 'URL=http://k3d-registry.localhost:12345/v2/_catalog; \
curl -X GET $URL || (echo "ERROR: Add \"127.0.0.1 k3d-registry.localhost\" to /etc/hosts" && exit 1)'
bash -c 'k3d cluster create syft-dev -p "8080:80@loadbalancer" --registry-use k3d-registry.localhost:12345; \
k3d cluster list'
[testenv:dev.k8s.deploy]
changedir = {toxinidir}/packages/grid
passenv=HOME, USER
allowlist_externals =
bash
commands =
bash -c '\
devspace use context k3d-syft-dev; \
devspace use namespace syft; \
devspace deploy --var CONTAINER_REGISTRY=k3d-registry.localhost:12345 --config=devspace.yaml'
[testenv:dev.k8s.cleanup]
changedir = {toxinidir}/packages/grid
allowlist_externals =
bash
commands =
bash -c '\
devspace use context k3d-syft-dev; \
devspace use namespace syft; \
devspace purge; \
rm -rf .devspace; echo ""; \
k3d cluster delete syft-dev; echo ""; \
k3d registry delete registry.localhost; echo "";\
kubectl config view'