forked from OpenMined/PySyft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_websocket_server.py
48 lines (37 loc) · 1.17 KB
/
run_websocket_server.py
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
from multiprocessing import Process
import syft as sy
from syft.workers.websocket_server import WebsocketServerWorker
import torch
import argparse
hook = sy.TorchHook(torch)
def start_proc(participant, kwargs): # pragma: no cover
""" helper function for spinning up a websocket participant """
def target():
server = participant(**kwargs)
server.start()
p = Process(target=target)
p.start()
return p
parser = argparse.ArgumentParser(description="Run websocket server worker.")
parser.add_argument(
"--port", "-p", type=int, help="port number of the websocket server worker, e.g. --port 8777"
)
parser.add_argument("--host", type=str, default="localhost", help="host for the connection")
parser.add_argument(
"--id", type=str, help="name (id) of the websocket server worker, e.g. --id alice"
)
parser.add_argument(
"--verbose",
"-v",
action="store_true",
help="if set, websocket server worker will be started in verbose mode",
)
args = parser.parse_args()
kwargs = {
"id": args.id,
"host": args.host,
"port": args.port,
"hook": hook,
"verbose": args.verbose,
}
server = start_proc(WebsocketServerWorker, kwargs)