-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.py
46 lines (36 loc) · 1.68 KB
/
debug.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
import argparse
import sys
from sys import platform
from nvflare.private.fed.app.simulator.simulator_runner import SimulatorRunner
def define_simulator_parser(simulator_parser):
simulator_parser.add_argument("job_folder")
simulator_parser.add_argument("-w", "--workspace", type=str, help="WORKSPACE folder")
simulator_parser.add_argument("-n", "--n_clients", type=int, help="number of clients")
simulator_parser.add_argument("-c", "--clients", type=str, help="client names list")
simulator_parser.add_argument("-t", "--threads", type=int, help="number of parallel running clients")
simulator_parser.add_argument("-gpu", "--gpu", type=str, help="list of GPU Device Ids, comma separated")
simulator_parser.add_argument("-m", "--max_clients", type=int, default=100, help="max number of clients")
def run_simulator(simulator_args):
simulator = SimulatorRunner(
job_folder=simulator_args.job_folder,
workspace=simulator_args.workspace,
clients=simulator_args.clients,
n_clients=simulator_args.n_clients,
threads=simulator_args.threads,
gpu=simulator_args.gpu,
max_clients=simulator_args.max_clients,
)
run_status = simulator.run()
return run_status
if __name__ == "__main__":
"""
This is the main program when running the NVFlare Simulator. Use the Flare simulator API,
create the SimulatorRunner object, do a setup(), then calls the run().
"""
if sys.version_info < (3, 7):
raise RuntimeError("Please use Python 3.7 or above.")
parser = argparse.ArgumentParser()
define_simulator_parser(parser)
args = parser.parse_args()
status = run_simulator(args)
sys.exit(status)