forked from OpenMined/PySyft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtox.ini
385 lines (337 loc) · 15.2 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
[tox]
envlist =
lint
syft.jupyter
syft.publish
syft.test.fast
syft.test.security
stack.test.integration
stack.test.integration.tls
stack.test.integration.windows
stack.test.integration.k8s
stack.test.integration.smpc
stack.test.course
grid.test.backend
requires =
tox-run-command
pip >= 21.2.1
skipsdist = True
[testenv]
basepython = python3
deps = pip
commands =
python --version
[testenv:lint]
; setupdir = {toxinidir}
; changedir = {toxinidir}
description = Linting
allowlist_externals =
bash
deps =
black[python2]
isort
protoc-wheel-0
pre-commit
commands =
bash -c "cd {toxinidir}/packages/syft; ./scripts/build_proto.sh"
black .
isort .
pre-commit run --all-files
# Syft
[testenv:syft]
deps =
-e{toxinidir}/packages/syft[dev]
changedir = {toxinidir}/packages/syft
description = Syft
commands =
pip list
[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.jupyter]
description = Jupyter Notebook with Editable Syft
deps =
{[testenv:syft]deps}
jupyter
commands =
pip install prompt-toolkit jupyter jupyterlab --upgrade # overrides grid deps in setup.cfg which break jupyter
jupyter lab --ip 0.0.0.0
[testenv:syft.test.fast]
description = Syft Unit Tests Fast
deps =
{[testenv:syft]deps}
changedir = {toxinidir}/packages/syft
commands =
pip list
pytest -m fast -n auto
[testenv:syft.test.security]
description = Security Checks for Syft
changedir = {toxinidir}/packages/syft
deps =
{[testenv:syft]deps}
commands =
pip install --upgrade pip
bandit -r src
safety check
[testenv:stack.test.integration]
description = Integration Tests for Core Stack
deps =
{[testenv:syft]deps}
changedir = {toxinidir}
allowlist_externals =
docker
grep
sleep
bash
setenv =
HAGRID_ART = false
PYTHONIOENCODING = utf-8
commands =
pip install -e packages/hagrid
docker --version
docker compose version
bash -c "docker volume rm test_domain_1_app-db-data --force || true"
bash -c "docker volume rm test_domain_2_app-db-data --force || true"
bash -c "docker volume rm test_network_1_app-db-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_network_1_tailscale-data --force || true"
bash -c "docker volume rm test_network_1_headscale-data --force || true"
bash -c 'HAGRID_ART=false hagrid launch test_network_1 network to docker:9081 --tail=false'
bash -c 'HAGRID_ART=false hagrid launch test_domain_1 domain to docker:9082 --build=false --tail=false'
bash -c 'HAGRID_ART=false hagrid launch test_domain_2 domain to docker:9083 --build=false --tail=false --headless=true'
docker ps
bash -c '(docker logs test_domain_1-frontend-1 -f &) | grep -q "event - compiled successfully\|nginx" || true'
bash -c '(docker logs test_network_1-frontend-1 -f &) | grep -q "event - compiled successfully\|nginx" || true'
bash -c '(docker logs test_domain_1-backend_stream-1 -f &) | grep -q "Application startup complete" || true'
bash -c '(docker logs test_domain_2-backend_stream-1 -f &) | grep -q "Application startup complete" || true'
bash -c '(docker logs test_network_1-backend_stream-1 -f &) | grep -q "Application startup complete" || true'
sleep 5
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
bash -c 'docker stop test_network_1-frontend-1 || true'
bash -c 'docker stop test_domain_1-frontend-1 || true'
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
pytest tests/integration -m general -p no:randomly --co
pytest tests/integration -m general -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no
pytest tests/integration -m e2e -p no:randomly --co
pytest tests/integration -m e2e -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no
pytest tests/integration -m security -p no:randomly --co
pytest tests/integration -m security -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no
bash -c 'HAGRID_ART=false hagrid land test_network_1'
bash -c 'HAGRID_ART=false hagrid land test_domain_1'
bash -c 'HAGRID_ART=false hagrid land test_domain_2'
[testenv:stack.test.integration.tls]
description = Integration Tests for Core Stack with TLS
deps =
{[testenv:syft]deps}
changedir = {toxinidir}
allowlist_externals =
docker
grep
sleep
bash
mkcert
mkdir
setenv =
HAGRID_ART = false
PYTHONIOENCODING = utf-8
IGNORE_TLS_ERRORS = True
CAROOT = {toxinidir}/packages/grid/tls
CERTS = {toxinidir}/packages/grid/traefik/certs
commands =
mkdir -p ./packages/grid/tls
bash -c "mkcert -cert-file={env:CERTS}/cert.pem -key-file={env:CERTS}/key.pem '*.openmined.grid' docker-host localhost 127.0.0.1 ::1"
; # mkcert -install # use this if you want to test in your own browser
pip install -e packages/hagrid
docker --version
docker compose version
bash -c "docker volume rm test_domain_1_app-db-data --force || true"
bash -c "docker volume rm test_domain_2_app-db-data --force || true"
bash -c "docker volume rm test_network_1_app-db-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_network_1_tailscale-data --force || true"
bash -c "docker volume rm test_network_1_headscale-data --force || true"
bash -c "HAGRID_ART=false hagrid launch test_network_1 network to docker:9081 --tail=false --tls --test --cert_store_path=./traefik/certs"
bash -c "HAGRID_ART=false hagrid launch test_domain_1 domain to docker:9082 --build=false --tail=false --tls --test --cert_store_path=./traefik/certs"
bash -c "HAGRID_ART=false hagrid launch test_domain_2 domain to docker:9083 --build=false --tail=false --headless=true --tls --test --cert_store_path=./traefik/certs"
docker ps
bash -c "(docker logs test_domain_1-frontend-1 -f &) | grep -q 'event - compiled successfully\|nginx' || true"
bash -c "(docker logs test_network_1-frontend-1 -f &) | grep -q 'event - compiled successfully\|nginx' || true"
bash -c "(docker logs test_domain_1-backend_stream-1 -f &) | grep -q 'Application startup complete' || true"
bash -c "(docker logs test_domain_2-backend_stream-1 -f &) | grep -q 'Application startup complete' || true"
bash -c "(docker logs test_network_1-backend_stream-1 -f &) | grep -q 'Application startup complete' || true"
sleep 5
pytest tests/integration -m frontend -p no:randomly --co
bash -c "REQUESTS_CA_BUNDLE={env:CAROOT}/rootCA.pem pytest tests/integration -m frontend -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no"
bash -c "docker stop test_network_1-frontend-1 || true"
bash -c "docker stop test_domain_1-frontend-1 || true"
pytest tests/integration -m network -p no:randomly --co
bash -c "REQUESTS_CA_BUNDLE={env:CAROOT}/rootCA.pem pytest tests/integration -m network -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no"
pytest tests/integration -m general -p no:randomly --co
bash -c "REQUESTS_CA_BUNDLE={env:CAROOT}/rootCA.pem pytest tests/integration -m general -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no"
pytest tests/integration -m e2e -p no:randomly --co
bash -c "REQUESTS_CA_BUNDLE={env:CAROOT}/rootCA.pem pytest tests/integration -m e2e -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no"
pytest tests/integration -m security -p no:randomly --co
bash -c "REQUESTS_CA_BUNDLE={env:CAROOT}/rootCA.pem pytest tests/integration -m security -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no"
bash -c "HAGRID_ART=false hagrid land test_network_1"
bash -c "HAGRID_ART=false hagrid land test_domain_1"
bash -c "HAGRID_ART=false hagrid land test_domain_2"
[testenv:stack.test.integration.windows]
description = Integration Tests for Core Stack
deps =
{[testenv:syft]deps}
changedir = {toxinidir}
allowlist_externals =
docker
bash
timeout
chcp
setenv =
HAGRID_ART = false
PYTHONIOENCODING = utf-8
commands =
chcp 65001
; pip install -e packages/hagrid
docker --version
; hagrid launch test_network_1 network to docker:9081 --tail=false --build=false --headless=true
; hagrid launch test_domain_1 domain to docker:9082 --tail=false --build=false --headless=true
; hagrid launch test_domain_2 domain to docker:9083 --tail=false --build=false --headless=true
; bash -c "(docker logs test_domain_1-frontend-1 -f &) | grep -q 'event - compiled successfully\|nginx' || true"
; bash -c "(docker logs test_network_1-frontend-1 -f &) | grep -q 'event - compiled successfully\|nginx' || true"
; bash -c "(docker logs test_domain_1-backend_stream-1 -f &) | grep -q 'Application startup complete' || true"
; bash -c "(docker logs test_domain_2-backend_stream-1 -f &) | grep -q 'Application startup complete' || true"
; bash -c "(docker logs test_network_1-backend_stream-1 -f &) | grep -q 'Application startup complete' || true"
; 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
; bash -c "docker stop test_network_1-frontend-1 || true"
; bash -c "docker stop test_domain_1-frontend-1 || true"
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
pytest tests/integration -m general -p no:randomly --co
pytest tests/integration -m general -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no
pytest tests/integration -m e2e -p no:randomly --co
pytest tests/integration -m e2e -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no
; pytest tests/integration -m security -p no:randomly --co
; pytest tests/integration -m security -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no
; hagrid land test_network_1
; hagrid land test_domain_1
; hagrid land test_domain_2
[testenv:stack.test.integration.smpc]
description = Integration Tests for Core Stack
deps =
{[testenv:syft]deps}
changedir = {toxinidir}
allowlist_externals =
docker
grep
sleep
bash
commands =
pip install -e packages/hagrid
docker --version
docker compose version
bash -c "docker volume rm test_domain_1_app-db-data --force || true"
bash -c "docker volume rm test_domain_2_app-db-data --force || true"
bash -c "docker volume rm test_domain_3_app-db-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_domain_3_tailscale-data --force || true"
bash -c 'HAGRID_ART=false hagrid launch test_domain_1 domain to docker:9082 --tail=false --headless=true'
bash -c 'HAGRID_ART=false hagrid launch test_domain_2 domain to docker:9083 --build=false --tail=false --headless=true'
bash -c 'HAGRID_ART=false hagrid launch test_domain_3 domain to docker:9084 --build=false --tail=false --headless=true'
docker ps
bash -c '(docker logs test_domain_1-backend_stream-1 -f &) | grep -q "Application startup complete" || true'
bash -c '(docker logs test_domain_2-backend_stream-1 -f &) | grep -q "Application startup complete" || true'
bash -c '(docker logs test_domain_3-backend_stream-1 -f &) | grep -q "Application startup complete" || true'
sleep 5
; perform spmc test
pytest tests/integration -m smpc -p no:randomly --co
pytest tests/integration -m smpc -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no
bash -c 'HAGRID_ART=false hagrid land test_domain_1'
bash -c 'HAGRID_ART=false hagrid land test_domain_2'
bash -c 'HAGRID_ART=false hagrid land test_domain_3'
[testenv:stack.test.integration.k8s]
description = Integration Tests for Core Stack
deps =
{[testenv:syft]deps}
changedir = {toxinidir}
passenv=HOME
allowlist_externals =
devspace
kubectl
minikube
grep
sleep
bash
kubectx
commands =
minikube version
bash -c 'minikube status && echo "minikube running" || echo "minikube starting" && minikube start --disk-size=40g'
minikube addons enable ingress
devspace --version
bash -c 'kubectl create namespace openmined || true'
devspace use namespace openmined
bash -c 'cd packages/grid && devspace deploy -b -p domain'
bash -c 'while ! (kubectl get ingress &) | grep -Eq "stack-ingress.*[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"; do echo "waiting for ingress" && sleep 1; done'
pytest tests/integration -m k8s -p no:randomly --co
bash -c 'TEST_DOMAIN_IP=`minikube ip` TEST_DOMAIN_PORT=80 pytest tests/integration -m k8s -vvvv -p no:randomly -p no:benchmark -o log_cli=True --capture=no'
[testenv:stack.test.course]
description = Integration Tests for Course Notebooks
deps =
{[testenv:syft]deps}
changedir = {toxinidir}
allowlist_externals =
docker
grep
sleep
bash
commands =
pip install -e packages/hagrid
pip install testbook prompt-toolkit jupyter
docker --version
docker compose version
bash -c "docker volume rm test_domain_1_app-db-data --force || true"
bash -c "docker volume rm test_domain_1_tailscale-data --force || true"
bash -c 'HAGRID_ART=false hagrid launch test_domain_1 domain to docker:8081 --tail=false --headless=true'
bash -c 'git clone https://github.com/OpenMined/courses.git tests/course/courses/ || true'
docker ps
bash -c '(docker logs test_domain_1-backend_stream-1 -f &) | grep -q "Application startup complete" || true'
sleep 5
; perform course notebook test
bash -c 'cd tests/course/courses && git checkout introduction-to-remote-data-science && git pull || true'
bash -c 'cp -r tests/course/tests/ tests/course/courses/'
bash -c 'cd tests/course/courses && pytest -p no:randomly'
bash -c 'HAGRID_ART=false hagrid land test_domain_1'
bash -c 'rm -rf tests/course/courses'
[testenv:grid.test.backend]
description = Tests for Grid Backend
deps =
{[testenv:syft]deps}
pytest
pytest-xdist[psutil]
poetry
importlib-metadata
changedir = {toxinidir}/packages/grid/backend
allowlist_externals =
bash
commands =
python --version
pip install -r requirements.txt
pip install importlib-metadata colorama # poetry is messing this up?
bash -c 'SQLALCHEMY_DATABASE_URI="sqlite:///file:test_db?mode=memory&cache=shared&uri=true" LOGURU_SINK="./grid.log" pytest grid/tests'
[flake8]
ignore =
W503
max-line-length = 120
exclude =
.tox
[mypy]
python_version = 3.9