-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·52 lines (44 loc) · 1.55 KB
/
main.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
49
50
51
52
import sys
from federated.nodes.server.components.coordinator import Coordinator
from federated.nodes.server.components.aggregator import Aggregator
from federated.nodes.server.components.deliverator import Deliverator
from federated.nodes.server.components.connector import Connector
from federated.nodes.server.components.registrar import Registrar
from federated.nodes.server.components.selector import Selector
from federated.nodes.client import Client
def usage():
return "Usage: python {} (server|client)".format(sys.argv[0])
testing = False
if __name__ == '__main__':
if len(sys.argv) < 2:
print(usage())
exit(1)
if sys.argv[1] == 'server':
# Run Server
if testing:
Coordinator(1).test()
else:
Coordinator(1).run()
elif sys.argv[1] == 'client':
# Check if client id has been provided
if len(sys.argv) != 3:
print(usage())
exit(1)
# Run Client
# print("Starting Client {}..".format(sys.argv[2]))
if testing:
Client('Mischievous Client').test()
else:
Client('Good Client').run()
elif sys.argv[1] == 'registrar':
Registrar(1, 1).run()
elif sys.argv[1] == 'aggregator':
Aggregator(1, 1).run()
elif sys.argv[1] == 'deliverator':
Deliverator(1).run()
elif sys.argv[1] == 'connector':
Connector(1).run()
elif sys.argv[1] == 'selector':
Selector(1, 1).run()
else:
print(usage())