-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
tox.ini
1757 lines (1556 loc) · 64.1 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.launch.datasite
dev.k8s.launch.gateway
dev.k8s.launch.datasite.highlow
dev.k8s.destroy.datasite.highlow
dev.k8s.registry
dev.k8s.start
dev.k8s.deploy
dev.k8s.hotreload
dev.k8s.info
dev.k8s.cleanup
dev.k8s.destroy
dev.k8s.destroyall
dev.k8s.install.signoz
lint
stack.test.integration
syft.docs
syft.jupyter
syft.publish
syft.test.security
syft.test.unit
syft.test.scenario
syft.test.scenario.sync
syft.test.notebook
syft.test.notebook.scenario
syft.test.notebook.scenario.sync
single_container.launch
single_container.destroy
stack.test.notebook
stack.test.integration.k8s
stack.test.notebook.scenario.k8s
stack.test.notebook.scenario.k8s.sync
stack.test.scenario.k8s
stack.test.scenario.k8s.sync
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
seaweedfs.test.unit
backend.test.basecpu
e2e.test.notebook
migration.prepare
migration.test
migration.k8s.prepare
migration.k8s.test
syft.api.snapshot
skipsdist = True
[testenv]
basepython = {env:TOX_PYTHON: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: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: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]
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
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 syft-ui-tests -t ui-test -f frontend.dockerfile .; \
docker run -t ui-test; \
fi'
[testenv:syft.docs]
description = Build Docs for Syft
changedir = {toxinidir}/docs
deps =
{[testenv:syft]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}
jupyter
jupyterlab
allowlist_externals =
bash
commands =
bash -c 'if [ -z "{posargs}" ]; then \
jupyter lab --ip 0.0.0.0; \
else \
jupyter lab --ip 0.0.0.0 --ServerApp.token={posargs}; \
fi'
[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.api.snapshot]
description = Syft API Snapshot Check
deps =
{[testenv:syft-minimal]deps}
changedir = {toxinidir}/packages/syft
allowlist_externals =
bash
setenv =
SAVE_SNAP = {env:SAVE_SNAP:False}
STABLE_RELEASE = {env:STABLE_RELEASE:False}
commands =
bash -c "echo Using SAVE_SNAP=${SAVE_SNAP}, STABLE_RELEASE=${STABLE_RELEASE}"
python -c 'import syft as sy; sy.show_api_diff()'
bash -c 'if [[ "$SAVE_SNAP" != "False" ]]; then \
python -c "import syft as sy; sy.take_api_snapshot()"; \
fi'
[testenv:syft.test.security]
description = Security Checks for Syft
changedir = {toxinidir}/packages/syft
deps =
{[testenv:syft]deps}
commands =
bandit -r src
# restrictedpython 6.2
# Temporarily ignore pytorch vulnerability warning here
# https://data.safetycli.com/v/71670/97c
# TODO: Remove `-i 71670` once torch is updated
safety check -i 70612 -i 71670
[testenv:syft.test.unit]
description = Syft Unit Tests
deps =
{[testenv:syft]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.scenario]
description = BigQuery Scenario Tests on Python Servers (L2)
changedir = {toxinidir}
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:python}
deps =
{[testenv:syft]deps}
pytest-asyncio
pytest-timeout
db-dtypes
google-cloud-bigquery
allowlist_externals =
bash
pytest
commands =
bash -c "echo Running L2 BigQuery Scenario Tests with ORCHESTRA_DEPLOYMENT_TYPE=$ORCHESTRA_DEPLOYMENT_TYPE"
bash -c "pytest -s --disable-warnings tests/scenariosv2/l2_test.py"
[testenv:syft.test.scenario.sync]
description = BigQuery Scenario Tests on Python Servers (L0)
changedir = {toxinidir}
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:python}
deps =
{[testenv:syft]deps}
pytest-asyncio
pytest-timeout
db-dtypes
google-cloud-bigquery
allowlist_externals =
bash
pytest
commands =
bash -c "echo Running L0 BigQuery Scenario Tests with ORCHESTRA_DEPLOYMENT_TYPE=$ORCHESTRA_DEPLOYMENT_TYPE"
bash -c "pytest -s --disable-warnings tests/scenariosv2/l0_test.py"
[testenv:stack.test.scenario.k8s]
description = BigQuery Scenario Tests on K8s (L2)
changedir = {toxinidir}
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:remote}
deps =
{[testenv:syft]deps}
pytest-asyncio
pytest-timeout
allowlist_externals =
bash
just
pytest
commands_pre =
just delete-all start-high deploy-high wait-high
commands =
bash -c "echo Running L2 BigQuery Scenario Tests on K8s with ORCHESTRA_DEPLOYMENT_TYPE=$ORCHESTRA_DEPLOYMENT_TYPE"
bash -c "pytest -s --disable-warnings tests/scenariosv2/l2_test.py"
commands_post =
just delete-all
[testenv:stack.test.scenario.k8s.sync]
description = BigQuery Scenario Tests on K8s (L0)
changedir = {toxinidir}
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:remote}
deps =
{[testenv:syft]deps}
pytest-asyncio
pytest-timeout
allowlist_externals =
bash
just
pytest
commands_pre =
just delete-all start-high deploy-high wait-high
just start-low deploy-low wait-low
commands =
bash -c "echo Running L0 BigQuery Scenario Tests on K8s with ORCHESTRA_DEPLOYMENT_TYPE=$ORCHESTRA_DEPLOYMENT_TYPE"
bash -c "pytest -s --disable-warnings tests/scenariosv2/l0_test.py"
commands_post =
just delete-all
[testenv:syft.test.notebook]
description = Syft Notebook Tests
deps =
-e{toxinidir}/packages/syft[dev,data_science]
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 -x --nbmake "$subfolder" \
-p no:randomly \
--ignore=tutorials/model-training \
--ignore=tutorials/version-upgrades \
-n $(python -c 'import multiprocessing; print(multiprocessing.cpu_count())') \
-vvvv && \
pytest -x --nbmake tutorials/model-training -p no:randomly -vvvv; \
else \
pytest -x --nbmake "$subfolder" -p no:randomly -k 'not 11-container-images-k8s.ipynb' -vvvv; \
fi \
done"
; pytest -x --nbmake api/0.8 -p no:randomly -vvvv
; pytest -x --nbmake api/0.9 -p no:randomly -vvvv
; pytest -x --nbmake tutorials -p no:randomly -vvvv
; pytest -x --nbmake tutorials/pandas-cookbook -p no:randomly -vvvv
# This is testing BQ without syncing and with in-memory python
[testenv:syft.test.notebook.scenario]
description = Syft Notebook Scenario Tests
deps =
{[testenv:syft]deps}
nbmake
db-dtypes
google-cloud-bigquery
aiosmtpd
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:scenarios/bigquery}
TEST_query_limit_size={env:test_query_limit_size:500000}
SERVER_URL = {env:SERVER_URL:http://localhost}
SERVER_PORT = {env:SERVER_PORT:8080}
NUM_TEST_USERS = {env:NUM_TEST_USERS:5}
NUM_TEST_JOBS = {env:NUM_TEST_JOBS:10}
commands =
python --version
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 -s -x --nbmake --nbmake-timeout=1000 "$subfolder" --ignore=scenarios/bigquery/sync --ignore=scenarios/bigquery/upgradability -p no:randomly -vvvv --log-cli-level=DEBUG --capture=no;\
done"
# This is testing BQ with syncing and with in-memory python
[testenv:syft.test.notebook.scenario.sync]
description = Syft Notebook Scenario Tests
deps =
{[testenv:syft]deps}
nbmake
db-dtypes
google-cloud-bigquery
aiosmtpd
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:scenarios/bigquery/sync}
TEST_BIGQUERY_APIS_LIVE = {env:TEST_BIGQUERY_APIS_LIVE:false}
TEST_query_limit_size={env:test_query_limit_size:500000}
SERVER_URL = {env:SERVER_URL:http://localhost}
SERVER_PORT = {env:SERVER_PORT:8080}
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 \
pytest -s -x --nbmake --nbmake-timeout=1000 "$subfolder" -p no:randomly -vvvv;\
done"
# This is testing BQ without syncing over k8s
[testenv:stack.test.notebook.scenario.k8s]
description = Scenario Notebook Tests for Core Stack using K8s
deps =
{[testenv:syft]deps}
nbmake
db-dtypes
google-cloud-bigquery
aiosmtpd
changedir = {toxinidir}
passenv=HOME, USER
allowlist_externals =
devspace
kubectl
grep
sleep
bash
k3d
echo
tox
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:remote}
DEVSPACE_PROFILE = bigquery-scenario-tests
GITHUB_CI = {env:GITHUB_CI:false}
SYFT_BASE_IMAGE_REGISTRY = {env:SYFT_BASE_IMAGE_REGISTRY:k3d-registry.localhost:5800}
DATASITE_CLUSTER_NAME = {env:DATASITE_CLUSTER_NAME:bigquery-high}
SERVER_URL = {env:SERVER_URL:http://localhost}
SERVER_PORT = {env:SERVER_PORT:8080}
TEST_EXTERNAL_REGISTRY = {env:TEST_EXTERNAL_REGISTRY:k3d-registry.localhost:5800}
TEST_QUERY_LIMIT_SIZE={env:TEST_QUERY_LIMIT_SIZE:500000}
TRACING={env:TRACING:False}
NUM_TEST_USERS = {env:NUM_TEST_USERS:5}
NUM_TEST_JOBS = {env:NUM_TEST_JOBS:10}
NUM_TEST_WORKERS = {env:NUM_TEST_WORKERS:2}
commands =
bash -c "python --version || true"
bash -c "echo Running with GITHUB_CI=$GITHUB_CI; date"
bash -c "echo Running with TEST_EXTERNAL_REGISTRY=$TEST_EXTERNAL_REGISTRY; date"
python -c 'import syft as sy; sy.stage_protocol_changes()'
k3d version
# Deleting Old Cluster
bash -c "k3d cluster delete ${DATASITE_CLUSTER_NAME} || true"
# Deleting registry & volumes
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c "docker volume rm k3d-${DATASITE_CLUSTER_NAME}-images --force || true"
# Create registry
tox -e dev.k8s.registry
# Creating bigquery-high cluster on port SERVER_PORT
bash -c '\
export CLUSTER_NAME=${DATASITE_CLUSTER_NAME} CLUSTER_HTTP_PORT=${SERVER_PORT} && \
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 bigquery-high
bash packages/grid/scripts/wait_for.sh service postgres --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service backend --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service proxy --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service seaweedfs --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service frontend --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash -c '(kubectl logs service/frontend --context k3d-${DATASITE_CLUSTER_NAME} --namespace syft -f &) | grep -q -E "Network:\s+https?://[a-zA-Z0-9.-]+:[0-9]+/" || true'
# Checking logs generated & startup of bigquery-high
bash -c '(kubectl logs service/backend --context k3d-${DATASITE_CLUSTER_NAME} --namespace syft -f &) | grep -q "Application startup complete" || true'
bash -c "pytest -s -x --nbmake notebooks/scenarios/bigquery -p no:randomly --ignore=notebooks/scenarios/bigquery/sync --ignore=notebooks/scenarios/bigquery/upgradability -vvvv --nbmake-timeout=1000 --log-cli-level=DEBUG --capture=no;"
# deleting clusters created
bash -c "CLUSTER_NAME=${DATASITE_CLUSTER_NAME} tox -e dev.k8s.destroy || true"
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c "docker volume rm k3d-${DATASITE_CLUSTER_NAME}-images --force || true"
# This is testing BQ with syncing over k8s
[testenv:stack.test.notebook.scenario.k8s.sync]
description = Syft Notebook Scenario Tests over k8s
deps =
{[testenv:syft]deps}
nbmake
db-dtypes
google-cloud-bigquery
aiosmtpd
changedir = {toxinidir}/notebooks
allowlist_externals =
bash
devspace
setenv =
DEV_MODE = {env:DEV_MODE:True}
DEVSPACE_PROFILE = bigquery-scenario-tests
TEST_NOTEBOOK_PATHS = {env:TEST_NOTEBOOK_PATHS:scenarios/bigquery/sync}
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:remote}
CLUSTER_NAME_HIGH = {env:CLUSTER_NAME_HIGH:bigquery-high}
CLUSTER_NAME_LOW = {env:CLUSTER_NAME_LOW:bigquery-low}
CLUSTER_HTTP_PORT_HIGH={env:CLUSTER_HTTP_PORT_HIGH:9081}
CLUSTER_HTTP_PORT_LOW={env:CLUSTER_HTTP_PORT_LOW:9083}
SYFT_BASE_IMAGE_REGISTRY = {env:SYFT_BASE_IMAGE_REGISTRY:k3d-registry.localhost:5800}
TEST_EXTERNAL_REGISTRY = {env:TEST_EXTERNAL_REGISTRY:k3d-registry.localhost:5800}
commands =
bash -c "echo Running highlow with ORCHESTRA_DEPLOYMENT_TYPE=$ORCHESTRA_DEPLOYMENT_TYPE DEV_MODE=$DEV_MODE TEST_NOTEBOOK_PATHS=$TEST_NOTEBOOK_PATHS; date"
bash -c 'tox -e dev.k8s.destroy.datasite.highlow'
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c "docker volume rm k3d-${CLUSTER_NAME_HIGH}-images --force || true"
bash -c "docker volume rm k3d-${CLUSTER_NAME_LOW}-images --force || true"
# Now create everything
bash -c 'tox -e dev.k8s.launch.datasite.highlow'
bash -c "for subfolder in $(echo ${TEST_NOTEBOOK_PATHS} | tr ',' ' ');\
do \
pytest -x --nbmake --nbmake-timeout=1000 "$subfolder" -p no:randomly -vvvv;\
done"
# Clean up again
bash -c 'tox -e dev.k8s.destroy.datasite.highlow'
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c "docker volume rm k3d-${CLUSTER_NAME_HIGH}-images --force || true"
bash -c "docker volume rm k3d-${CLUSTER_NAME_LOW}-images --force || true"
[testenv:single_container.launch]
description = Launch a single backend container using the dockerfile
changedir = {toxinidir}/packages
setenv =
N_CONSUMERS = {env:N_CONSUMERS:1}
SERVER_NAME = {env:SERVER_NAME:test_datasite_sc}
SERVER_TYPE = {env:SERVER_TYPE:datasite}
SERVER_PORT = {env:SERVER_PORT:8080}
allowlist_externals =
bash
commands =
bash -c 'tox -e single_container.destroy'
bash -c 'docker build -f grid/backend/backend.dockerfile . -t openmined/syft-backend:local-dev'
bash -c 'docker run -d \
-e SERVER_NAME=${SERVER_NAME} \
-e SERVER_TYPE=${SERVER_TYPE} \
-e N_CONSUMERS=${N_CONSUMERS} \
-e SINGLE_CONTAINER_MODE=true \
-e CREATE_PRODUCER=true \
-e INMEMORY_WORKERS=true \
-p ${SERVER_PORT}:80 --add-host=host.docker.internal:host-gateway \
--name ${SERVER_NAME} openmined/syft-backend:local-dev'
[testenv:single_container.destroy]
description = Destroy the single backend container run using single_container.launch
changedir = {toxinidir}/packages
setenv =
SERVER_NAME = {env:SERVER_NAME:test_datasite_sc}
allowlist_externals =
bash
commands =
# Image is not cleaned up
bash -c 'docker stop ${SERVER_NAME} || true'
bash -c 'docker rm ${SERVER_NAME} || true'
[testenv:stack.test.notebook]
description = Stack Notebook Tests
deps =
{[testenv:syft]deps}
nbmake
changedir = {toxinidir}/notebooks
allowlist_externals =
bash
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:remote}
DEV_MODE = {env:DEV_MODE:True}
TEST_NOTEBOOK_PATHS = {env:TEST_NOTEBOOK_PATHS:api/0.8}
ENABLE_SIGNUP=True
SERVER_URL = {env:SERVER_URL:http://localhost}
SERVER_PORT = {env:SERVER_PORT:8080}
commands =
# Volume cleanup
bash -c 'docker volume rm -f $(docker volume ls -q --filter "label=orgs.openmined.syft") || true'
bash -c 'docker volume rm -f $(docker volume ls -q --filter "label=com.docker.volume.anonymous") || true'
bash -c 'docker network rm -f $(docker network 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 -x --nbmake --nbmake-timeout=1000 "$subfolder" -p no:randomly -vvvv -k 'not 11-container-images-k8s.ipynb';\
done"
; pytest -x --nbmake --nbmake-timeout=1000 api/0.8 -p no:randomly -vvvv
; pytest -x --nbmake --nbmake-timeout=1000 api/0.9 -p no:randomly -vvvv
; pytest -x --nbmake --nbmake-timeout=1000 tutorials -p no:randomly -vvvv
; pytest -x --nbmake --nbmake-timeout=1000 tutorials/pandas-cookbook -p no:randomly -vvvv
bash -c 'docker volume rm -f $(docker volume ls -q --filter "label=orgs.openmined.syft") || true'
bash -c 'docker volume rm -f $(docker volume ls -q --filter "label=com.docker.volume.anonymous") || true'
bash -c 'docker network rm -f $(docker network ls -q --filter "label=orgs.openmined.syft") || true'
[testenv:frontend.generate.types]
description = Generate Types for Frontend
deps =
{[testenv:syft]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:syft.test.integration]
description = Integration Tests for Syft Stack
deps =
{[testenv:syft]deps}
pytest-asyncio
changedir = {toxinidir}
passenv=HOME, USER
allowlist_externals =
bash
setenv =
PYTEST_MODULES = {env:PYTEST_MODULES:asyncio local_server}
ASSOCIATION_REQUEST_AUTO_APPROVAL = {env:ASSOCIATION_REQUEST_AUTO_APPROVAL:true}
PYTEST_FLAGS = {env:PYTEST_FLAGS:--ignore=tests/integration/local/job_test.py}
commands =
python -c 'import syft as sy; sy.stage_protocol_changes()'
# Run Integration Tests
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 $PYTEST_FLAGS; \
return=$?; \
echo "Finished $i"; \
date; \
if [[ $return -ne 0 ]]; then \
exit $return; \
fi; \
done'
[testenv:stack.test.integration.k8s]
description = Integration Tests for Core Stack using K8s
deps =
{[testenv:syft]deps}
pytest-asyncio
changedir = {toxinidir}
passenv=HOME, USER, AZURE_BLOB_STORAGE_KEY
allowlist_externals =
devspace
kubectl
grep
sleep
bash
kubectx
k3d
echo
tox
setenv =
SERVER_PORT = {env:SERVER_PORT:9082}
GITHUB_CI = {env:GITHUB_CI:false}
PYTEST_MODULES = {env:PYTEST_MODULES:frontend network container_workload}
DATASITE_CLUSTER_NAME = {env:DATASITE_CLUSTER_NAME:test-datasite-1}
GATEWAY_CLUSTER_NAME = {env:GATEWAY_CLUSTER_NAME:test-gateway-1}
ASSOCIATION_REQUEST_AUTO_APPROVAL = {env:ASSOCIATION_REQUEST_AUTO_APPROVAL:true}
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
# Deleting Old Cluster
bash -c "k3d cluster delete ${DATASITE_CLUSTER_NAME} || true"
bash -c "k3d cluster delete ${GATEWAY_CLUSTER_NAME} || true"
# Deleting registry & volumes
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c "docker volume rm k3d-${DATASITE_CLUSTER_NAME}-images --force || true"
bash -c "docker volume rm k3d-${GATEWAY_CLUSTER_NAME}-images --force || true"
# Create registry
tox -e dev.k8s.registry
# Creating test-gateway-1 cluster on port 9081
bash -c '\
export CLUSTER_NAME=${GATEWAY_CLUSTER_NAME} CLUSTER_HTTP_PORT=9081 DEVSPACE_PROFILE=gateway && \
tox -e dev.k8s.start && \
tox -e dev.k8s.deploy'
# Creating test-datasite-1 cluster on port 9082
bash -c '\
export CLUSTER_NAME=${DATASITE_CLUSTER_NAME} CLUSTER_HTTP_PORT=9082 DEVSPACE_PROFILE=datasite-tunnel && \
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 test gateway 1
bash packages/grid/scripts/wait_for.sh service postgres --context k3d-{env:GATEWAY_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service backend --context k3d-{env:GATEWAY_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service proxy --context k3d-{env:GATEWAY_CLUSTER_NAME} --namespace syft
# wait for test datasite 1
bash packages/grid/scripts/wait_for.sh service postgres --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service backend --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service proxy --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service seaweedfs --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service frontend --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash -c '(kubectl logs service/frontend --context k3d-${DATASITE_CLUSTER_NAME} --namespace syft -f &) | grep -q -E "Network:\s+https?://[a-zA-Z0-9.-]+:[0-9]+/" || true'
# Checking logs generated & startup of test-datasite 1
bash -c '(kubectl logs service/backend --context k3d-${DATASITE_CLUSTER_NAME} --namespace syft -f &) | grep -q "Application startup complete" || true'
# Checking logs generated & startup of testgateway1
bash -c '(kubectl logs service/backend --context k3d-${GATEWAY_CLUSTER_NAME} --namespace syft -f &) | grep -q "Application startup complete" || true'
# Run Integration Tests
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'
# deleting clusters created
bash -c "CLUSTER_NAME=${DATASITE_CLUSTER_NAME} tox -e dev.k8s.destroy || true"
bash -c "CLUSTER_NAME=${GATEWAY_CLUSTER_NAME} tox -e dev.k8s.destroy || true"
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c "docker volume rm k3d-${DATASITE_CLUSTER_NAME}-images --force || true"
bash -c "docker volume rm k3d-${GATEWAY_CLUSTER_NAME}-images --force || true"
[testenv:stack.test.notebook.k8s]
description = Notebook Tests for Core Stack using K8s
deps =
{[testenv:syft]deps}
nbmake
changedir = {toxinidir}
passenv=HOME, USER
allowlist_externals =
devspace
kubectl
grep
sleep
bash
k3d
echo
tox
setenv =
ORCHESTRA_DEPLOYMENT_TYPE = {env:ORCHESTRA_DEPLOYMENT_TYPE:remote}
GITHUB_CI = {env:GITHUB_CI:false}
SYFT_BASE_IMAGE_REGISTRY = {env:SYFT_BASE_IMAGE_REGISTRY:k3d-registry.localhost:5800}
DATASITE_CLUSTER_NAME = {env:DATASITE_CLUSTER_NAME:test-datasite-1}
SERVER_URL = {env:SERVER_URL:http://localhost}
SERVER_PORT = {env:SERVER_PORT:8080}
commands =
bash -c "echo Running with GITHUB_CI=$GITHUB_CI; date"
python -c 'import syft as sy; sy.stage_protocol_changes()'
k3d version
# Deleting Old Cluster
bash -c "k3d cluster delete ${DATASITE_CLUSTER_NAME} || true"
# Deleting registry & volumes
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c "docker volume rm k3d-${DATASITE_CLUSTER_NAME}-images --force || true"
# Create registry
tox -e dev.k8s.registry
# Creating test-datasite-1 cluster on port SERVER_PORT
bash -c '\
export CLUSTER_NAME=${DATASITE_CLUSTER_NAME} CLUSTER_HTTP_PORT=${SERVER_PORT} && \
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 test-datasite-1
bash packages/grid/scripts/wait_for.sh service postgres --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service backend --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service proxy --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service seaweedfs --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash packages/grid/scripts/wait_for.sh service frontend --context k3d-{env:DATASITE_CLUSTER_NAME} --namespace syft
bash -c '(kubectl logs service/frontend --context k3d-${DATASITE_CLUSTER_NAME} --namespace syft -f &) | grep -q -E "Network:\s+https?://[a-zA-Z0-9.-]+:[0-9]+/" || true'
# Checking logs generated & startup of test-datasite 1
bash -c '(kubectl logs service/backend --context k3d-${DATASITE_CLUSTER_NAME} --namespace syft -f &) | grep -q "Application startup complete" || true'
bash -c "pytest -x --nbmake notebooks/api/0.8 -p no:randomly -k 'not 14-container-images.ipynb' -vvvv --nbmake-timeout=1000"
# deleting clusters created
bash -c "CLUSTER_NAME=${DATASITE_CLUSTER_NAME} tox -e dev.k8s.destroy || true"
bash -c "k3d registry delete k3d-registry.localhost || true"
bash -c "docker volume rm k3d-${DATASITE_CLUSTER_NAME}-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:dev.k8s.ready]
description = Check readiness of k8s deployement
changedir = {toxinidir}/packages/grid
allowlist_externals =
bash
tox
curl
setenv =
CLUSTER_NAME = {env:CLUSTER_NAME:syft}
CLUSTER_HTTP_PORT = {env:SERVER_PORT:8080}
; Usage for posargs: names of the relevant services among {frontend backend proxy postgres seaweedfs registry}
commands =
bash -c "env; date; k3d version"
# Frontend
bash -c "if echo '{posargs}' | grep -q 'frontend'; then \
echo 'Checking readiness of frontend'; \
./scripts/wait_for.sh service frontend --context k3d-$CLUSTER_NAME --namespace syft && \
(kubectl logs service/frontend --context k3d-$CLUSTER_NAME --namespace syft -f &) | grep -q -E 'Network:\s+https?://[a-zA-Z0-9.-]+:[0-9]+/' || true; \
fi"
# Backend
bash -c "if echo '{posargs}' | grep -q 'backend'; then \
echo 'Checking readiness of backend'; \
./scripts/wait_for.sh service backend --context k3d-$CLUSTER_NAME --namespace syft && \
(kubectl logs service/backend --context k3d-$CLUSTER_NAME --namespace syft -f &) | grep -q 'Application startup complete' || true; \
fi"
# Postgres
bash -c "if echo '{posargs}' | grep -q 'postgres'; then echo 'Checking readiness of Postgres'; ./scripts/wait_for.sh service postgres --context k3d-$CLUSTER_NAME --namespace syft; fi"
# Proxy
bash -c "if echo '{posargs}' | grep -q 'proxy'; then echo 'Checking readiness of proxy'; ./scripts/wait_for.sh service proxy --context k3d-$CLUSTER_NAME --namespace syft; fi"
# Seaweedfs
bash -c "if echo '{posargs}' | grep -q 'seaweedfs'; then echo 'Checking readiness of SeaweedFS'; ./scripts/wait_for.sh service seaweedfs --context k3d-$CLUSTER_NAME --namespace syft; fi"
# Registry
bash -c "if echo '{posargs}' | grep -q 'registry'; then echo 'Checking readiness of Registry'; ./scripts/wait_for.sh service registry --context k3d-$CLUSTER_NAME --namespace syft; fi"
# Extra
bash -c "curl http://localhost:${CLUSTER_HTTP_PORT}/api/v2/metadata"
[testenv:syft.test.helm]
description = Test Helm Chart for Kubernetes