@@ -115,7 +115,7 @@ def run_impl(
115115 message_center = self .message_center )
116116
117117 # start unified inference gateway process if not started
118- FedMLDeployMasterJobRunner .start_device_inference_gateway (inference_port = inference_port )
118+ FedMLDeployMasterJobRunner .start_device_inference_gateway ()
119119
120120 # start inference monitor process
121121 FedMLDeployMasterJobRunner .stop_device_inference_monitor (
@@ -144,7 +144,7 @@ def run_impl(
144144 # No device is added, updated or removed
145145 logging .info ("No device is added, updated or removed. No action needed for reconciliation." )
146146 ip = GeneralConstants .get_ip_address (self .request_json )
147- master_port = os . getenv ( "FEDML_MASTER_PORT" , None )
147+ master_port = ServerConstants . get_inference_master_gateway_port ( )
148148 if master_port is not None :
149149 inference_port = int (master_port )
150150 model_inference_port = inference_port
@@ -299,9 +299,7 @@ def process_deployment_result_message(self, topic=None, payload=None):
299299 else :
300300 # This is the last worker that failed, so we should continue to "ABORTED" status
301301 model_config_parameters = self .request_json ["parameters" ]
302- inference_port = model_config_parameters .get ("server_internal_port" ,
303- ServerConstants .MODEL_INFERENCE_DEFAULT_PORT )
304- inference_port_external = model_config_parameters .get ("server_external_port" , inference_port )
302+ inference_port_external = ServerConstants .get_inference_master_gateway_port ()
305303 ip = GeneralConstants .get_ip_address (self .request_json )
306304 if ip .startswith ("http://" ) or ip .startswith ("https://" ):
307305 model_inference_url = "{}/inference/{}" .format (ip , end_point_id )
@@ -369,12 +367,7 @@ def process_deployment_result_message(self, topic=None, payload=None):
369367 """
370368 When all the devices have finished the add / delete / update operation
371369 """
372- # Generate one unified inference api
373- # Note that here we use the gateway port instead of the inference port that is used by the slave device
374- model_config_parameters = request_json ["parameters" ]
375- inference_port = model_config_parameters .get ("server_internal_port" ,
376- ServerConstants .MODEL_INFERENCE_DEFAULT_PORT )
377- inference_port_external = model_config_parameters .get ("server_external_port" , inference_port )
370+ inference_port_external = ServerConstants .get_inference_master_gateway_port ()
378371 ip = GeneralConstants .get_ip_address (request_json )
379372
380373 if ip .startswith ("http://" ) or ip .startswith ("https://" ):
@@ -457,12 +450,10 @@ def cleanup_runner_process(self, run_id):
457450 ServerConstants .cleanup_run_process (run_id , not_kill_subprocess = True )
458451
459452 @staticmethod
460- def start_device_inference_gateway (inference_port = ServerConstants . MODEL_INFERENCE_DEFAULT_PORT ):
453+ def start_device_inference_gateway ():
461454 # start unified inference server
462455 python_program = get_python_program ()
463- master_port = os .getenv ("FEDML_MASTER_PORT" , None )
464- if master_port is not None :
465- inference_port = int (master_port )
456+ inference_port = ServerConstants .get_inference_master_gateway_port ()
466457 if not ServerConstants .is_running_on_k8s ():
467458 logging .info (f"start the model inference gateway..." )
468459 inference_gw_cmd = "fedml.computing.scheduler.model_scheduler.device_model_inference:api"
@@ -543,7 +534,7 @@ def recover_inference_and_monitor():
543534 if not is_activated :
544535 continue
545536
546- FedMLDeployMasterJobRunner .start_device_inference_gateway (inference_port = inference_port )
537+ FedMLDeployMasterJobRunner .start_device_inference_gateway ()
547538
548539 FedMLDeployMasterJobRunner .stop_device_inference_monitor (
549540 run_id , end_point_name , model_id , model_name , model_version )
@@ -757,9 +748,7 @@ def parse_model_run_params(running_json):
757748 model_version = model_config ["model_version" ]
758749 model_config_parameters = running_json .get ("parameters" , {})
759750
760- inference_port = model_config_parameters .get ("server_internal_port" , # Internal port is for the gateway
761- ServerConstants .MODEL_INFERENCE_DEFAULT_PORT )
762- inference_port_external = model_config_parameters .get ("server_external_port" , inference_port )
751+ inference_port = ServerConstants .get_inference_master_gateway_port ()
763752
764753 return run_id , end_point_name , token , user_id , user_name , device_ids , device_objs , model_config , model_name , \
765754 model_id , model_storage_url , scale_min , scale_max , inference_engine , model_is_from_open , \
0 commit comments