-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_local.py
31 lines (23 loc) · 977 Bytes
/
run_local.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
import argparse
from client import *
import requests
import threading
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", default="http://127.0.0.1:22222", type=str)
parser.add_argument("--client", default=5, type=int)
parser.add_argument("--exp", default=1, type=int)
parser.add_argument("--round", default=5, type=int)
parser.add_argument("--num", default=300, type=int)
parser.add_argument("--delay", default=5, type=int)
args = parser.parse_args()
init = requests.get(f"{args.ip}/initialize/{args.client}/{args.exp}/{args.round}")
print(init)
clients = []
for i in range(args.client):
client = Client(args.ip, args.round, args.delay, args.num, i, args.exp)
clients.append(client)
for client in clients:
thread = threading.Thread(target=client.task)
thread.start()
print("Federated learning done")