@@ -51,6 +51,16 @@ def send_iteration_to_frontend(i):
51
51
logging .warning ('Frontend may be down' )
52
52
53
53
54
+ def end_frontend ():
55
+ logging .info ('Sending end signal to frontend' )
56
+ try :
57
+ requests .post (
58
+ url = 'http://{}:{}/finish' .format (hosts ['frontend' ]['host' ],
59
+ hosts ['frontend' ]['port' ]))
60
+ except :
61
+ logging .warning ('Frontend may be down' )
62
+
63
+
54
64
def restart_frontend ():
55
65
logging .info ('Restarting frontend' )
56
66
try :
@@ -64,16 +74,14 @@ def restart_frontend():
64
74
logging .warning ('Frontend may be down' )
65
75
66
76
67
- def main (op_mode ):
68
- # TODO: Configure epochs and everything from here
69
- NUM_ITERATIONS = 50
77
+ def main (op_mode , communication_rounds ):
70
78
all_results = []
71
79
ch = client_handler .ClientHandler (clients = hosts ['clients' ],
72
80
OPERATION_MODE = op_mode )
73
81
#train_accs = {}
74
82
start = time .time ()
75
83
# restart_frontend()
76
- for i in range (NUM_ITERATIONS ):
84
+ for i in range (communication_rounds ):
77
85
logging .info ('Iteration {}...' .format (i ))
78
86
send_iteration_to_frontend (i )
79
87
@@ -131,6 +139,7 @@ def main(op_mode):
131
139
132
140
logging .info ('All results:' )
133
141
logging .info (all_results )
142
+ end_frontend ()
134
143
135
144
136
145
if __name__ == '__main__' :
@@ -142,9 +151,15 @@ def main(op_mode):
142
151
'Operation mode. '
143
152
'Options: wait_all (default), n_firsts, timeout'
144
153
))
154
+ parser .add_argument ('-c' ,
155
+ '--communication-rounds' ,
156
+ type = int ,
157
+ required = False ,
158
+ default = 50 ,
159
+ help = 'Number of communication rounds . Default : 50 )
145
160
args = parser .parse_args ()
146
161
try :
147
- main (op_mode = args .operation_mode )
162
+ main (op_mode = args .operation_mode , args . communication_rounds )
148
163
except Exception :
149
164
logging .error ("Fatal error in main loop" , exc_info = True )
150
165
0 commit comments