-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
tox.ini
1061 lines (930 loc) · 35.7 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
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[tox]
envlist =
dev.k8s.registry
dev.k8s.start
dev.k8s.deploy
dev.k8s.hotreload
dev.k8s.info
dev.k8s.cleanup
dev.k8s.destroy
dev.k8s.destroyall
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.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.test.helm.upgrade
syft.protocol.check
syftcli.test.unit
syftcli.publish
syftcli.build
backend.test.basecpu
e2e.test.notebook
skipsdist = True
[testenv]
basepython = python3
commands =
python --version
setenv =
UV_HTTP_TIMEOUT = 600
# Syft
[testenv:syft]
deps =
-e{toxinidir}/packages/syft[dev,data_science]
changedir = {toxinidir}/packages/syft
description = Syft
allowlist_externals =
bash
commands =
bash -c 'uv pip list || pip list'
# Syft Minimal - without dev+datascience packages
[testenv:syft-minimal]
deps =
-e{toxinidir}/packages/syft
changedir = {toxinidir}/packages/syft
description = Syft
allowlist_externals =
bash
commands =
bash -c 'uv pip list || pip list'
[testenv:hagrid]
deps =
-e{toxinidir}/packages/hagrid[dev]
changedir = {toxinidir}/packages/hagrid
description = Syft
allowlist_externals =
bash
commands =
bash -c 'uv pip list || pip list'
[testenv:syftcli]
deps =
-e{toxinidir}/packages/syftcli[dev]
changedir = {toxinidir}/packages/syftcli
description = Syft CLI
allowlist_externals =
bash
commands =
bash -c 'uv pip list || pip list'
[testenv:syft.publish]
changedir = {toxinidir}/packages/syft
description = Build and Publish Syft Wheel
deps =
build
commands =
python -c 'from shutil import rmtree; rmtree("build", True); rmtree("dist", True)'
python -m build .
[testenv:hagrid.publish]
changedir = {toxinidir}/packages/hagrid
description = Build and Publish Hagrid Wheel
deps =
build
commands =
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
deps =
build
allowlist_externals =
bash
commands =
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
deps =
-e{toxinidir}/packages/syftcli[build]
allowlist_externals =
bash
setenv =
SYFT_CLI_VERSION = {env:SYFT_CLI_VERSION}
commands =
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 \
uv pip install -e "../../hagrid"; \
else \
uv 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 -f $(docker volume ls -q --filter "label=orgs.openmined.syft") || 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'
bash -c 'docker volume rm -f $(docker volume ls -q --filter "label=orgs.openmined.syft") || true'
[testenv:stack.test.integration]
description = Integration Tests for Core Stack
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
pytest
changedir = {toxinidir}
allowlist_externals =
docker
grep
sleep
bash
chcp
passenv=HOME, USER, AZURE_BLOB_STORAGE_KEY
setenv =
HAGRID_FLAGS = {env:HAGRID_FLAGS:--tag=local --release=development --dev}
EMULATION = {env:EMULATION:false}
HAGRID_ART = false
PYTHONIOENCODING = utf-8
PYTEST_MODULES = {env:PYTEST_MODULES:frontend container_workload network}
commands =
bash -c "whoami; id;"
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 \
echo "Installing latest syft and hagrid"; \
uv pip install --force hagrid syft; \
elif [[ "$HAGRID_FLAGS" == *"beta"* ]]; then \
echo "Installing beta syft and hagrid"; \
uv pip install --force hagrid; \
uv pip install --force -U --pre syft; \
else \
echo "Using local syft and 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 --filter "label=orgs.openmined.syft") || true'
bash -c 'docker volume rm -f $(docker volume ls -q --filter "label=orgs.openmined.syft") || true'
python -c 'import syft as sy; sy.stage_protocol_changes()'
; Make sure that pacakge-cache is owned by the current user
; instead of docker creating it as root
bash -c 'mkdir -p packages/grid/data/package-cache'
bash -c 'HAGRID_ART=$HAGRID_ART hagrid launch test-gateway-1 gateway to docker:9081 $HAGRID_FLAGS --no-health-checks --verbose --no-warnings --build'
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 --build'
; 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 --build'
; 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'
bash -c '\
PYTEST_MODULES=($PYTEST_MODULES); \
for i in "${PYTEST_MODULES[@]}"; do \
echo "Starting test for $i"; date; \
pytest tests/integration -m $i -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no; \
return=$?; \
echo "Finished $i"; \
date; \
if [[ $return -ne 0 ]]; then \
exit $return; \
fi; \
done'
; shutdown
bash -c "echo Killing Nodes; date"
bash -c 'HAGRID_ART=false hagrid land all --force'
bash -c 'docker rm -f $(docker ps -a -q --filter "label=orgs.openmined.syft") || true'
bash -c 'docker volume rm -f $(docker volume ls -q --filter "label=orgs.openmined.syft") || true'
[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 =
jupyter lab --ip 0.0.0.0 --ServerApp.token={posargs}
[testenv:syft.protocol.check]
description = Syft Protocol Check
deps =
{[testenv:syft-minimal]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.test.security]
description = Security Checks for Syft
changedir = {toxinidir}/packages/syft
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
commands =
bandit -r src
# ansible 8.4.0
# restrictedpython 6.2
safety check -i 60840 -i 54229 -i 54230 -i 42923 -i 54230 -i 54229 -i 62044 -i 65213 -i 54564
[testenv:syft.test.unit]
description = Syft Unit Tests
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
allowlist_externals =
bash
uv
changedir = {toxinidir}/packages/syft
setenv =
ENABLE_SIGNUP=False
commands =
bash -c 'ulimit -n 4096 || true'
pytest -n auto --dist loadgroup --durations=20 --disable-warnings
[testenv:syft.test.notebook]
description = Syft Notebook Tests
deps =
-e{toxinidir}/packages/syft[dev,data_science]
{[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={env:ENABLE_SIGNUP:False}
BUMP_PROTOCOL={env:BUMP_PROTOCOL:False}
commands =
bash -c 'if [[ $BUMP_PROTOCOL == "True" ]]; then \
python -c "import syft as sy; sy.bump_protocol_version()"; \
fi;'
bash -c "echo Running with ORCHESTRA_DEPLOYMENT_TYPE=$ORCHESTRA_DEPLOYMENT_TYPE DEV_MODE=$DEV_MODE TEST_NOTEBOOK_PATHS=$TEST_NOTEBOOK_PATHS; ENABLE_SIGNUP=$ENABLE_SIGNUP; 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 -k 'not 11-container-images-k8s.ipynb' -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}
ENABLE_SIGNUP=True
commands =
# Volume cleanup
bash -c 'hagrid land all --force || true'
bash -c 'docker volume rm -f $(docker volume ls -q --filter "label=orgs.openmined.syft") || 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 -k 'not 11-container-images-k8s.ipynb' --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
bash -c 'hagrid land all --force'
bash -c 'docker volume rm -f $(docker volume ls -q --filter "label=orgs.openmined.syft") || true'
[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.12
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
tox
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:k8s}
NODE_PORT = {env:NODE_PORT:9082}
GITHUB_CI = {env:GITHUB_CI:false}
PYTEST_MODULES = {env:PYTEST_MODULES:frontend container_workload}
SYFT_BASE_IMAGE_REGISTRY = {env:SYFT_BASE_IMAGE_REGISTRY:k3d-registry.localhost:5800}
commands =
bash -c "echo Running with GITHUB_CI=$GITHUB_CI; date"
python -c 'import syft as sy; sy.stage_protocol_changes()'
k3d version
# Since cluster name cannot have underscore and environment variable cannot have hyphen
# we are passing a grouped name for node names
# bash -c "docker rm $(docker ps -aq) --force || true"
# Deleting current cluster
bash -c "k3d cluster delete testgateway1 || true"
bash -c "k3d cluster delete testdomain1 || true"
# Deleting registry & volumes
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c "docker volume rm k3d-testgateway1-images --force || true"
bash -c "docker volume rm k3d-testdomain1-images --force || true"
# Create registry
tox -e dev.k8s.registry
# Creating testgateway1 cluster on port 9081
bash -c '\
export CLUSTER_NAME=testgateway1 CLUSTER_HTTP_PORT=9081 DEVSPACE_PROFILE=gateway && \
tox -e dev.k8s.start && \
tox -e dev.k8s.deploy'
# Creating testdomain1 cluster on port 9082
bash -c '\
export CLUSTER_NAME=testdomain1 CLUSTER_HTTP_PORT=9082 && \
tox -e dev.k8s.start && \
tox -e dev.k8s.deploy'
# free up build cache after build of images
bash -c 'if [[ "$GITHUB_CI" != "false" ]]; then \
docker image prune --all --force; \
docker builder prune --all --force; \
fi'
sleep 30
# wait for front end
bash packages/grid/scripts/wait_for.sh service frontend --context k3d-testdomain1 --namespace syft
bash -c '(kubectl logs service/frontend --context k3d-testdomain1 --namespace syft -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-testgateway1 --namespace syft
bash packages/grid/scripts/wait_for.sh service backend --context k3d-testgateway1 --namespace syft
bash packages/grid/scripts/wait_for.sh service proxy --context k3d-testgateway1 --namespace syft
# wait for test domain 1
bash packages/grid/scripts/wait_for.sh service mongo --context k3d-testdomain1 --namespace syft
bash packages/grid/scripts/wait_for.sh service backend --context k3d-testdomain1 --namespace syft
bash packages/grid/scripts/wait_for.sh service proxy --context k3d-testdomain1 --namespace syft
bash packages/grid/scripts/wait_for.sh service seaweedfs --context k3d-testdomain1 --namespace syft
# Checking logs generated & startup of test-domain 1
bash -c '(kubectl logs service/backend --context k3d-testdomain1 --namespace syft -f &) | grep -q "Application startup complete" || true'
# Checking logs generated & startup of testgateway1
bash -c '(kubectl logs service/backend --context k3d-testgateway1 --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'
# Integration + Gateway Connection Tests
# Gateway tests are not run in kuberetes, as currently,it does not have a way to configure
# high/low side warning flag.
bash -c "source ./scripts/get_k8s_secret_ci.sh; \
pytest tests/integration/network -k 'not test_domain_gateway_user_code' -p no:randomly -vvvv"
# Shutting down the gateway cluster to free up space, as the
# below code does not require gateway cluster
bash -c "CLUSTER_NAME=testgateway1 tox -e dev.k8s.destroy || true"
bash -c "docker volume rm k3d-testgateway1-images --force || true"
; container workload
; bash -c 'if [[ "$PYTEST_MODULES" == *"container_workload"* ]]; then \
; echo "Starting Container Workload test"; date; \
; pytest tests/integration -m container_workload -p no:randomly --co; \
; pytest tests/integration -m container_workload -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no; \
; return=$?; \
; echo "Finished container workload"; date; \
; exit $return; \
; fi'
bash -c "source ./scripts/get_k8s_secret_ci.sh; \
pytest --nbmake notebooks/api/0.8 -p no:randomly -k 'not 10-container-images.ipynb' -vvvv --nbmake-timeout=1000"
# deleting clusters created
bash -c "CLUSTER_NAME=testdomain1 tox -e dev.k8s.destroy || 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-testdomain1-images --force || true"
[testenv:syft.build.helm]
description = Build Helm Chart for Kubernetes
changedir = {toxinidir}
passenv=HOME, USER
allowlist_externals =
bash
helm
commands =
bash -c 'cd packages/grid/helm && \
python3 generate_helm_notes.py ./syft/templates'
bash -c 'cd packages/grid/helm && \
helm lint syft'
[testenv:syft.lint.helm]
description = Lint helm chart
changedir = {toxinidir}/packages/grid/helm
passenv=HOME, USER
allowlist_externals =
bash
commands =
bash -c 'kube-linter lint ./syft --config ./kubelinter-config.yaml'
[testenv:syft.package.helm]
description = Package Helm Chart for Kubernetes
deps =
changedir = {toxinidir}
passenv=HOME, USER
allowlist_externals =
bash
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
changedir = {toxinidir}/packages/grid
passenv=HOME, USER, EXTERNAL_REGISTRY_USERNAME, EXTERNAL_REGISTRY_PASSWORD
allowlist_externals =
bash
tox
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:k8s}
NODE_PORT = {env:NODE_PORT:8080}
NODE_URL = {env:NODE_URL:http://localhost}
EXCLUDE_NOTEBOOKS = {env:EXCLUDE_NOTEBOOKS:not 10-container-images.ipynb}
SYFT_VERSION = {env:SYFT_VERSION:local}
EXTERNAL_REGISTRY = {env:EXTERNAL_REGISTRY:k3d-registry.localhost:5800}
; env vars for dev.k8s.start
CLUSTER_NAME = testdomain
CLUSTER_HTTP_PORT = {env:NODE_PORT:8080}
commands =
bash -c "env; date; k3d version"
bash -c "k3d cluster delete ${CLUSTER_NAME} || true"
tox -e dev.k8s.start
bash -c 'if [[ $SYFT_VERSION == "local" ]]; then \
echo "Installing local helm charts"; \
helm install ${CLUSTER_NAME} ./helm/syft -f ./helm/values.dev.yaml --kube-context k3d-${CLUSTER_NAME} --namespace syft --create-namespace; \
else \
echo "Installing helm charts from repo for syft version: ${SYFT_VERSION}"; \
helm repo add openmined https://openmined.github.io/PySyft/helm; \
helm repo update openmined; \
helm install ${CLUSTER_NAME} openmined/syft --version=${SYFT_VERSION} -f ./helm/values.dev.yaml --kube-context k3d-${CLUSTER_NAME} --namespace syft --create-namespace; \
fi'
; wait for everything else to be loaded
bash -c './scripts/wait_for.sh service frontend --context k3d-$CLUSTER_NAME --namespace syft'
bash -c '(kubectl logs service/frontend --context k3d-$CLUSTER_NAME --namespace syft -f &) | grep -q -E "Network:\s+https?://[a-zA-Z0-9.-]+:[0-9]+/" || true'
bash -c './scripts/wait_for.sh service mongo --context k3d-$CLUSTER_NAME --namespace syft'
bash -c './scripts/wait_for.sh service backend --context k3d-$CLUSTER_NAME --namespace syft'
bash -c './scripts/wait_for.sh service proxy --context k3d-$CLUSTER_NAME --namespace syft'
bash -c '(kubectl logs service/backend --context k3d-$CLUSTER_NAME --namespace syft -f &) | grep -q "Application startup complete" || true'
# Run Notebook tests
tox -e e2e.test.notebook
bash -c "k3d cluster delete ${CLUSTER_NAME} || true"
[testenv:syft.test.helm.upgrade]
description = Test helm upgrade
changedir = {toxinidir}/packages/grid/
passenv=HOME,USER,KUBE_CONTEXT
setenv =
UPGRADE_TYPE = {env:UPGRADE_TYPE:ProdToBeta}
allowlist_externals =
bash
commands =
bash ./scripts/helm_upgrade.sh {env:UPGRADE_TYPE}
[testenv:syftcli.test.unit]
description = Syft CLI Unit Tests
deps =
{[testenv:syftcli]deps}
changedir = {toxinidir}/packages/syftcli
allowlist_externals =
uv
pytest
commands =
pytest
[testenv:dev.k8s.registry]
description = Start local Kubernetes registry with k3d
changedir = {toxinidir}
passenv=HOME,USER
allowlist_externals =
bash
sudo
commands =
; check k3d version
bash -c 'k3d --version'
; create registry
bash -c 'k3d registry create registry.localhost --port 5800 -v $HOME/.k3d-registry:/var/lib/registry || true'
; add patches to host
bash -c 'if ! grep -q k3d-registry.localhost /etc/hosts; then sudo {envpython} scripts/patch_hosts.py --add-k3d-registry --fix-docker-hosts; fi'
; Fail this command if registry is not working
bash -c 'curl --retry 5 --retry-all-errors http://k3d-registry.localhost:5800/v2/_catalog'
[testenv:dev.k8s.patch.coredns]
description = Patch CoreDNS to resolve k3d-registry.localhost
changedir = {toxinidir}
passenv=HOME,USER,CLUSTER_NAME
setenv =
CLUSTER_NAME = {env:CLUSTER_NAME:syft-dev}
allowlist_externals =
bash
commands =
; patch coredns so k3d-registry.localhost works in k3d
bash -c 'kubectl apply -f ./scripts/k8s-coredns-custom.yml --context k3d-${CLUSTER_NAME}'
; restarts coredns
bash -c 'kubectl delete pod -n kube-system -l k8s-app=kube-dns --context k3d-${CLUSTER_NAME}'
[testenv:dev.k8s.start]
description = Start local Kubernetes registry & cluster with k3d
changedir = {toxinidir}
passenv = HOME, USER
setenv =
CLUSTER_NAME = {env:CLUSTER_NAME:syft-dev}
CLUSTER_HTTP_PORT = {env:CLUSTER_HTTP_PORT:8080}
allowlist_externals =
bash
sleep
tox
commands =
; start registry
tox -e dev.k8s.registry
; for NodePort to work add the following --> -p "NodePort:NodePort@loadbalancer"
bash -c 'k3d cluster create ${CLUSTER_NAME} -p "${CLUSTER_HTTP_PORT}:80@loadbalancer" --registry-use k3d-registry.localhost:5800 && \
kubectl --context k3d-${CLUSTER_NAME} create namespace syft || true'
; patch coredns
tox -e dev.k8s.patch.coredns
; dump cluster info
tox -e dev.k8s.info
[testenv:dev.k8s.deploy]
description = Deploy Syft to a local Kubernetes cluster with Devspace
changedir = {toxinidir}/packages/grid
passenv = HOME, USER, DEVSPACE_PROFILE
setenv=
CLUSTER_NAME = {env:CLUSTER_NAME:syft-dev}
allowlist_externals =
bash
commands =
; deploy syft helm charts
bash -c '\
if [[ -n "${DEVSPACE_PROFILE}" ]]; then export DEVSPACE_PROFILE="-p ${DEVSPACE_PROFILE}"; fi && \
devspace deploy -b --kube-context k3d-${CLUSTER_NAME} --no-warn ${DEVSPACE_PROFILE} --namespace syft --var CONTAINER_REGISTRY=k3d-registry.localhost:5800'
[testenv:dev.k8s.hotreload]
description = Start development with hot-reload in Kubernetes
changedir = {toxinidir}/packages/grid
passenv = HOME, USER, DEVSPACE_PROFILE
setenv=
CLUSTER_NAME = {env:CLUSTER_NAME:syft-dev}
allowlist_externals =
bash
commands =
; deploy syft helm charts with hot-reload
bash -c '\
if [[ -n "${DEVSPACE_PROFILE}" ]]; then export DEVSPACE_PROFILE="-p ${DEVSPACE_PROFILE}"; fi && \
devspace dev --kube-context k3d-${CLUSTER_NAME} --no-warn ${DEVSPACE_PROFILE} --namespace syft --var CONTAINER_REGISTRY=k3d-registry.localhost:5800'
[testenv:dev.k8s.info]
description = Gather info about the localKubernetes cluster
passenv = HOME, USER
ignore_errors = True
allowlist_externals =
k3d
kubectl
commands =
k3d cluster list
kubectl cluster-info
kubectl config current-context
kubectl get namespaces
[testenv:dev.k8s.cleanup]
description = Cleanup Syft deployment and associated resources, but keep the cluster running
changedir = {toxinidir}/packages/grid
passenv=HOME, USER
setenv=
CLUSTER_NAME = {env:CLUSTER_NAME:syft-dev}
allowlist_externals =
bash
commands =
bash -c 'devspace purge --force-purge --kube-context k3d-${CLUSTER_NAME} --no-warn --namespace syft; sleep 3'
bash -c 'devspace cleanup images --kube-context k3d-${CLUSTER_NAME} --no-warn --namespace syft --var CONTAINER_REGISTRY=k3d-registry.localhost:5800 || true'
bash -c 'kubectl --context k3d-${CLUSTER_NAME} delete namespace syft --now=true || true'
[testenv:dev.k8s.destroy]
description = Destroy local Kubernetes cluster
changedir = {toxinidir}/packages/grid
passenv = HOME, USER
setenv=
CLUSTER_NAME = {env:CLUSTER_NAME:syft-dev}
allowlist_externals =
tox
bash
commands =
; purge deployment and dangling resources
tox -e dev.k8s.cleanup
; destroy cluster
bash -c '\
rm -rf .devspace; echo ""; \
k3d cluster delete ${CLUSTER_NAME};'
[testenv:dev.k8s.destroyall]
description = Destroy both local Kubernetes cluster and registry
changedir = {toxinidir}
passenv = HOME, USER, CLUSTER_NAME
ignore_errors=True
allowlist_externals =
bash
tox
commands =
; destroy cluster
tox -e dev.k8s.destroy
; destroy registry
bash -c 'k3d registry delete registry.localhost || true'
bash -c 'sudo rm -rf ~/.k3d-registry'
[testenv:backend.test.basecpu]
description = Base CPU Docker Image Test
changedir = {toxinidir}/packages
allowlist_externals =
docker
bash
setenv =
PIP_PACKAGES = {env:PIP_PACKAGES:llama-index opendp}
SYSTEM_PACKAGES = {env:SYSTEM_PACKAGES:curl wget}
commands =
bash -c 'docker buildx use default || true'
; Build the base image
bash -c 'docker build -f ./grid/backend/worker_cpu.dockerfile . -t cpu-worker:latest'
bash -c 'docker rmi cpu-worker:latest'