@@ -89,29 +89,29 @@ def __init__(self):
89
89
parts = self ._sagemaker_port_range .split ("-" )
90
90
low = int (parts [0 ])
91
91
hi = int (parts [1 ])
92
- self ._tfs_grpc_port = []
93
- self ._tfs_rest_port = []
92
+ self ._tfs_grpc_ports = []
93
+ self ._tfs_rest_ports = []
94
94
if low + 2 * self ._tfs_instance_count > hi :
95
95
raise ValueError ("not enough ports available in SAGEMAKER_SAFE_PORT_RANGE ({})"
96
96
.format (self ._sagemaker_port_range ))
97
97
# select non-overlapping grpc and rest ports based on tfs instance count
98
98
for i in range (self ._tfs_instance_count ):
99
- self ._tfs_grpc_port .append (str (low + 2 * i ))
100
- self ._tfs_rest_port .append (str (low + 2 * i + 1 ))
99
+ self ._tfs_grpc_ports .append (str (low + 2 * i ))
100
+ self ._tfs_rest_ports .append (str (low + 2 * i + 1 ))
101
101
# concat selected ports respectively in order to pass them to python service
102
- self ._tfs_grpc_concat_port = self ._concat_port (self ._tfs_grpc_port )
103
- self ._tfs_rest_concat_port = self ._concat_port (self ._tfs_rest_port )
102
+ self ._tfs_grpc_concat_ports = self ._concat_ports (self ._tfs_grpc_ports )
103
+ self ._tfs_rest_concat_ports = self ._concat_ports (self ._tfs_rest_ports )
104
104
else :
105
105
# just use the standard default ports
106
- self ._tfs_grpc_port = ["9000" ]
107
- self ._tfs_rest_port = ["8501" ]
106
+ self ._tfs_grpc_ports = ["9000" ]
107
+ self ._tfs_rest_ports = ["8501" ]
108
108
# provide single concat port here for default case
109
- self ._tfs_grpc_concat_port = "9000"
110
- self ._tfs_rest_concat_port = "8501"
109
+ self ._tfs_grpc_concat_ports = "9000"
110
+ self ._tfs_rest_concat_ports = "8501"
111
111
112
112
# set environment variable for python service
113
- os .environ ["TFS_GRPC_PORT " ] = self ._tfs_grpc_concat_port
114
- os .environ ["TFS_REST_PORT " ] = self ._tfs_rest_concat_port
113
+ os .environ ["TFS_GRPC_PORTS " ] = self ._tfs_grpc_concat_ports
114
+ os .environ ["TFS_REST_PORTS " ] = self ._tfs_rest_concat_ports
115
115
116
116
def _need_python_service (self ):
117
117
if os .path .exists (INFERENCE_PATH ):
@@ -120,7 +120,7 @@ def _need_python_service(self):
120
120
and os .environ .get ("SAGEMAKER_MULTI_MODEL_UNIVERSAL_PREFIX" ):
121
121
self ._enable_python_service = True
122
122
123
- def _concat_port (self , ports ):
123
+ def _concat_ports (self , ports ):
124
124
str_ports = [str (port ) for port in ports ]
125
125
concat_str_ports = "," .join (str_ports )
126
126
return concat_str_ports
@@ -198,13 +198,13 @@ def _setup_gunicorn(self):
198
198
gunicorn_command = (
199
199
"gunicorn -b unix:/tmp/gunicorn.sock -k {} --chdir /sagemaker "
200
200
"--workers {} --threads {} "
201
- "{}{} -e TFS_GRPC_PORT ={} -e TFS_REST_PORT ={} "
201
+ "{}{} -e TFS_GRPC_PORTS ={} -e TFS_REST_PORTS ={} "
202
202
"-e SAGEMAKER_MULTI_MODEL={} -e SAGEMAKER_SAFE_PORT_RANGE={} "
203
203
"-e SAGEMAKER_TFS_WAIT_TIME_SECONDS={} "
204
204
"python_service:app" ).format (self ._gunicorn_worker_class ,
205
205
self ._gunicorn_workers , self ._gunicorn_threads ,
206
206
python_path_option , "," .join (python_path_content ),
207
- self ._tfs_grpc_concat_port , self ._tfs_rest_concat_port ,
207
+ self ._tfs_grpc_concat_ports , self ._tfs_rest_concat_ports ,
208
208
self ._tfs_enable_multi_model_endpoint ,
209
209
self ._sagemaker_port_range ,
210
210
self ._tfs_wait_time_seconds )
@@ -234,7 +234,7 @@ def _download_scripts(self, bucket, prefix):
234
234
def _create_nginx_tfs_upstream (self ):
235
235
indentation = " "
236
236
tfs_upstream = ""
237
- for port in self ._tfs_rest_port :
237
+ for port in self ._tfs_rest_ports :
238
238
tfs_upstream += "{}server localhost:{};\n " .format (indentation , port )
239
239
tfs_upstream = tfs_upstream [len (indentation ):- 2 ]
240
240
@@ -338,7 +338,7 @@ def _wait_for_gunicorn(self):
338
338
339
339
def _wait_for_tfs (self ):
340
340
for i in range (self ._tfs_instance_count ):
341
- tfs_utils .wait_for_model (self ._tfs_rest_port [i ],
341
+ tfs_utils .wait_for_model (self ._tfs_rest_ports [i ],
342
342
self ._tfs_default_model_name , self ._tfs_wait_time_seconds )
343
343
344
344
@contextmanager
@@ -374,8 +374,8 @@ def _restart_single_tfs(self, pid):
374
374
375
375
def _start_single_tfs (self , instance_id ):
376
376
cmd = tfs_utils .tfs_command (
377
- self ._tfs_grpc_port [instance_id ],
378
- self ._tfs_rest_port [instance_id ],
377
+ self ._tfs_grpc_ports [instance_id ],
378
+ self ._tfs_rest_ports [instance_id ],
379
379
self ._tfs_config_path ,
380
380
self ._tfs_enable_batching ,
381
381
self ._tfs_batching_config_path ,
0 commit comments