forked from OpenMined/PySyft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
283 lines (253 loc) · 9.25 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
[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
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:notebook.test]
description = Notebook Tests
deps =
{[testenv:syft]deps}
nbmake
changedir = {toxinidir}/notebooks
commands =
pytest --nbmake api/0.8 -p no:randomly -vvvv
[testenv:stack.test.integration]
description = Integration Tests for Core Stack
deps =
{[testenv:syft]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'
bash -c 'HAGRID_ART=$HAGRID_ART hagrid launch test_domain_1 domain to docker:9082 $HAGRID_FLAGS --no-health-checks'
bash -c 'HAGRID_ART=$HAGRID_ART hagrid launch test_domain_2 domain to docker:9083 --headless $HAGRID_FLAGS --no-vpn --no-health-checks'
; 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 "Listening on.*\|.*ready in.*" || 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 = -r {toxinidir}/docs/requirements.txt
allowlist_externals =
make
echo
commands =
python --version
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 jupyterlab --upgrade
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}
commands =
pip install --upgrade pip
bandit -r src
safety check -i 51668 -i 51516 -i 51549
[testenv:syft.test.unit]
description = Syft Unit Tests
deps =
{[testenv:syft]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}
allowlist_externals =
grep
bash
passenv=HOME, USER
setenv =
LOCAL_ENCLAVE_PORT=8010
ENABLE_OBLV=true
DOMAIN_CONNECTION_PORT=8010
commands =
pip install pyoblv==0.2.0
python -c "import platform; import os; os.system('pip install jaxlib==0.3.14 -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
setenv =
ORCHESTRA_NODE_TYPE = {env:ORCHESTRA_NODE_TYPE:python}
commands =
pytest --nbmake api/0.8 -p no:randomly -vvvv
[testenv:stack.test.notebook]
description = Stack Notebook Tests
deps =
{[testenv:syft]deps}
{[testenv:hagrid]deps}
nbmake
changedir = {toxinidir}/notebooks
setenv =
ORCHESTRA_NODE_TYPE = {env:ORCHESTRA_NODE_TYPE:enclave}
commands =
pytest --nbmake api/0.8 -p no:randomly -vvvv
[mypy]
python_version = 3.10
; remove once we get rid of protobuf
disable_error_code = attr-defined, valid-type, no-untyped-call, arg-type