99from abc import ABC
1010import yaml
1111from fedml .computing .scheduler .comm_utils .job_utils import JobRunnerUtils
12+ from fedml .computing .scheduler .comm_utils .network_util import return_this_device_connectivity_type
13+
1214from fedml .core .mlops import MLOpsRuntimeLog
1315from fedml .computing .scheduler .comm_utils import file_utils
1416from .device_client_constants import ClientConstants
@@ -234,8 +236,11 @@ def run_impl(self, run_extend_queue_list, sender_message_center,
234236 running_model_name , inference_output_url , inference_model_version , model_metadata , model_config = \
235237 "" , "" , model_version , {}, {}
236238
239+ # ip and connectivity
240+ worker_ip = GeneralConstants .get_ip_address (self .request_json )
241+ connectivity = return_this_device_connectivity_type ()
242+
237243 if op == "add" :
238- worker_ip = GeneralConstants .get_ip_address (self .request_json )
239244 for rank in range (prev_rank + 1 , prev_rank + 1 + op_num ):
240245 try :
241246 running_model_name , inference_output_url , inference_model_version , model_metadata , model_config = \
@@ -269,7 +274,9 @@ def run_impl(self, run_extend_queue_list, sender_message_center,
269274 result_payload = self .send_deployment_results (
270275 end_point_name , self .edge_id , ClientConstants .MSG_MODELOPS_DEPLOYMENT_STATUS_DEPLOYED ,
271276 model_id , model_name , inference_output_url , model_version , inference_port_external ,
272- inference_engine , model_metadata , model_config , replica_no = rank + 1 )
277+ inference_engine , model_metadata , model_config , replica_no = rank + 1 ,
278+ connectivity = connectivity
279+ )
273280
274281 if inference_port_external != inference_port :
275282 # Save internal port to local db
@@ -278,7 +285,9 @@ def run_impl(self, run_extend_queue_list, sender_message_center,
278285 result_payload = self .construct_deployment_results (
279286 end_point_name , self .edge_id , ClientConstants .MSG_MODELOPS_DEPLOYMENT_STATUS_DEPLOYED ,
280287 model_id , model_name , inference_output_url , model_version , inference_port ,
281- inference_engine , model_metadata , model_config , replica_no = rank + 1 )
288+ inference_engine , model_metadata , model_config , replica_no = rank + 1 ,
289+ connectivity = connectivity
290+ )
282291
283292 FedMLModelDatabase .get_instance ().set_deployment_result (
284293 run_id , end_point_name , model_name , model_version , self .edge_id ,
@@ -326,7 +335,6 @@ def run_impl(self, run_extend_queue_list, sender_message_center,
326335 return True
327336 elif op == "update" or op == "rollback" :
328337 # Update is combine of delete and add
329- worker_ip = GeneralConstants .get_ip_address (self .request_json )
330338 for rank in replica_rank_to_update :
331339 # Delete a replica (container) if exists
332340 self .replica_handler .remove_replica (rank )
@@ -402,15 +410,19 @@ def run_impl(self, run_extend_queue_list, sender_message_center,
402410 result_payload = self .send_deployment_results (
403411 end_point_name , self .edge_id , ClientConstants .MSG_MODELOPS_DEPLOYMENT_STATUS_DEPLOYED ,
404412 model_id , model_name , inference_output_url , model_version , inference_port_external ,
405- inference_engine , model_metadata , model_config , replica_no = rank + 1 )
413+ inference_engine , model_metadata , model_config , replica_no = rank + 1 ,
414+ connectivity = connectivity
415+ )
406416
407417 if inference_port_external != inference_port : # Save internal port to local db
408418 logging .info ("inference_port_external {} != inference_port {}" .format (
409419 inference_port_external , inference_port ))
410420 result_payload = self .construct_deployment_results (
411421 end_point_name , self .edge_id , ClientConstants .MSG_MODELOPS_DEPLOYMENT_STATUS_DEPLOYED ,
412422 model_id , model_name , inference_output_url , model_version , inference_port ,
413- inference_engine , model_metadata , model_config , replica_no = rank + 1 )
423+ inference_engine , model_metadata , model_config , replica_no = rank + 1 ,
424+ connectivity = connectivity
425+ )
414426
415427 FedMLModelDatabase .get_instance ().set_deployment_result (
416428 run_id , end_point_name , model_name , model_version , self .edge_id ,
@@ -433,7 +445,8 @@ def run_impl(self, run_extend_queue_list, sender_message_center,
433445 def construct_deployment_results (self , end_point_name , device_id , model_status ,
434446 model_id , model_name , model_inference_url ,
435447 model_version , inference_port , inference_engine ,
436- model_metadata , model_config , replica_no = 1 ):
448+ model_metadata , model_config , replica_no = 1 ,
449+ connectivity = ClientConstants .WORKER_CONNECTIVITY_TYPE_DEFAULT ):
437450 deployment_results_payload = {"end_point_id" : self .run_id , "end_point_name" : end_point_name ,
438451 "model_id" : model_id , "model_name" : model_name ,
439452 "model_url" : model_inference_url , "model_version" : model_version ,
@@ -444,6 +457,7 @@ def construct_deployment_results(self, end_point_name, device_id, model_status,
444457 "model_status" : model_status ,
445458 "inference_port" : inference_port ,
446459 "replica_no" : replica_no ,
460+ "connectivity_type" : connectivity ,
447461 }
448462 return deployment_results_payload
449463
@@ -466,15 +480,16 @@ def construct_deployment_status(self, end_point_name, device_id,
466480 def send_deployment_results (self , end_point_name , device_id , model_status ,
467481 model_id , model_name , model_inference_url ,
468482 model_version , inference_port , inference_engine ,
469- model_metadata , model_config , replica_no = 1 ):
483+ model_metadata , model_config , replica_no = 1 ,
484+ connectivity = ClientConstants .WORKER_CONNECTIVITY_TYPE_DEFAULT ):
470485 deployment_results_topic = "model_device/model_device/return_deployment_result/{}/{}" .format (
471486 self .run_id , device_id )
472487
473488 deployment_results_payload = self .construct_deployment_results (
474489 end_point_name , device_id , model_status ,
475490 model_id , model_name , model_inference_url ,
476491 model_version , inference_port , inference_engine ,
477- model_metadata , model_config , replica_no = replica_no )
492+ model_metadata , model_config , replica_no = replica_no , connectivity = connectivity )
478493
479494 logging .info ("[client] send_deployment_results: topic {}, payload {}." .format (deployment_results_topic ,
480495 deployment_results_payload ))
0 commit comments