forked from OpenMined/PySyft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtox.ini
More file actions
470 lines (422 loc) · 15.2 KB
/
tox.ini
File metadata and controls
470 lines (422 loc) · 15.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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
[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.vm
frontend.test.unit
frontend.test.e2e
frontend.generate.types
skipsdist = True
[testenv]
basepython = python3
install_command = pip install --find-links https://whls.blob.core.windows.net/unstable/index.html {opts} {packages}
commands =
python --version
setenv =
PIP_FIND_LINKS=https://whls.blob.core.windows.net/unstable/index.html
# Syft
[testenv:syft]
deps =
-e{toxinidir}/packages/syft[dev]
changedir = {toxinidir}/packages/syft
description = Syft
setenv =
PIP_FIND_LINKS=https://whls.blob.core.windows.net/unstable/index.html
commands =
pip list
[testenv:hagrid]
deps =
-e{toxinidir}/packages/hagrid[dev]
changedir = {toxinidir}/packages/hagrid
description = Syft
setenv =
PIP_FIND_LINKS=https://whls.blob.core.windows.net/unstable/index.html
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: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}
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 'HAGRID_ART=$HAGRID_ART hagrid launch test_domain_1 domain to docker:9081 $HAGRID_FLAGS --no-health-checks --verbose'
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 playwright@1.33 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 =
PIP_FIND_LINKS=https://whls.blob.core.windows.net/unstable/index.html
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_2_mongo-data --force || true"
bash -c "docker volume rm test_domain_2_credentials-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_domain_1_seaweedfs-data --force || true"
bash -c "docker volume rm test_domain_2_seaweedfs-data --force || true"
bash -c "docker volume rm test_domain_1_app-redis-data --force || true"
bash -c "docker volume rm test_domain_2_app-redis-data --force || true"
bash -c "docker volume rm test_gateway_1_app-redis-data --force || true"
bash -c "docker volume rm test_domain_1_tailscale-data --force || true"
bash -c "docker volume rm test_domain_2_tailscale-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"
bash -c 'HAGRID_ART=$HAGRID_ART hagrid launch test_gateway_1 network to docker:9081 $HAGRID_FLAGS --no-health-checks --verbose'
bash -c 'HAGRID_ART=$HAGRID_ART hagrid launch test_domain_1 domain to docker:9082 $HAGRID_FLAGS --no-health-checks --verbose'
bash -c 'HAGRID_ART=$HAGRID_ART hagrid launch test_domain_2 domain to docker:9083 --headless $HAGRID_FLAGS --no-vpn --no-health-checks --verbose'
; 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
setenv =
PIP_FIND_LINKS=https://whls.blob.core.windows.net/unstable/index.html
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
jupyter
jupyterlab
commands =
pip install -e packages/hagrid
pip install jupyter --upgrade
pip install jupyterlab==3.6.3
jupyter lab --ip 0.0.0.0 --ServerApp.token={posargs}
[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
safety check -i 42923 -i 54229 -i 54230
[testenv:syft.test.unit]
description = Syft Unit Tests
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
changedir = {toxinidir}/packages/syft
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
commands =
pip install oblv-ctl==0.3.1
python -c "import platform; import os; os.system('pip install jaxlib==0.4.10 -f https://whls.blob.core.windows.net/unstable/index.html') if platform.system().lower() == 'windows' else ''"
# 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_NODE_TYPE = {env:ORCHESTRA_NODE_TYPE:python}
DEV_MODE = {env:DEV_MODE:True}
TEST_NOTEBOOK_PATHS = {env:TEST_NOTEBOOK_PATHS:api/0.8,tutorials}
commands =
bash -c "echo Running with ORCHESTRA_NODE_TYPE=$ORCHESTRA_NODE_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 -n $(python -c 'import multiprocessing; print(multiprocessing.cpu_count())') -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_NODE_TYPE = {env:ORCHESTRA_NODE_TYPE:enclave}
DEV_MODE = {env:DEV_MODE:True}
TEST_NOTEBOOK_PATHS = {env:TEST_NOTEBOOK_PATHS:api/0.8,tutorials}
commands =
bash -c "echo Running with ORCHESTRA_NODE_TYPE=$ORCHESTRA_NODE_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;\
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_NODE_TYPE = {env:ORCHESTRA_NODE_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: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