Skip to content

Commit 1ee7c09

Browse files
Default GRPC timeout for EI & Allow timeout to be configurable (#135)
1 parent ffe2fd7 commit 1ee7c09

File tree

6 files changed

+153
-216
lines changed

6 files changed

+153
-216
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ def read(fname):
3737
install_requires=['sagemaker-container-support'],
3838
extras_require={
3939
'test': ['tox', 'flake8', 'pytest', 'pytest-cov', 'pytest-xdist', 'mock',
40-
'sagemaker', 'tensorflow']
40+
'sagemaker', 'tensorflow', 'tensorflow-serving-api']
4141
},
4242
)

src/tf_container/proxy_client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
1111
# express or implied. See the License for the specific language governing
1212
# permissions and limitations under the License.
13+
import os
1314

1415
import numpy as np
1516
from google.protobuf import json_format
@@ -25,6 +26,11 @@
2526

2627
from tf_container.run import logger as _logger
2728

29+
INFERENCE_ACCELERATOR_PRESENT_ENV = 'SAGEMAKER_INFERENCE_ACCELERATOR_PRESENT'
30+
TF_SERVING_GRPC_REQUEST_TIMEOUT_ENV = 'SAGEMAKER_TFS_GRPC_REQUEST_TIMEOUT'
31+
32+
DEFAULT_GRPC_REQUEST_TIMEOUT_FOR_INFERENCE_ACCELERATOR = 30.0
33+
2834
REGRESSION = 'tensorflow/serving/regression'
2935
CLASSIFY = 'tensorflow/serving/classify'
3036
INFERENCE = 'tensorflow/serving/inference'
@@ -37,6 +43,11 @@ def __init__(self, tf_serving_port, host='localhost', request_timeout=10.0,
3743
model_name=GENERIC_MODEL_NAME,
3844
input_tensor_name=PREDICT_INPUTS,
3945
signature_name=DEFAULT_SERVING_SIGNATURE_DEF_KEY):
46+
if os.environ.get(TF_SERVING_GRPC_REQUEST_TIMEOUT_ENV):
47+
request_timeout = float(os.environ.get(TF_SERVING_GRPC_REQUEST_TIMEOUT_ENV))
48+
elif os.environ.get(INFERENCE_ACCELERATOR_PRESENT_ENV) == 'true':
49+
request_timeout = DEFAULT_GRPC_REQUEST_TIMEOUT_FOR_INFERENCE_ACCELERATOR
50+
4051
self.tf_serving_port = tf_serving_port
4152
self.host = host
4253
self.request_timeout = request_timeout

test/unit/test_experiment_trainer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2-
#
2+
#
33
# Licensed under the Apache License, Version 2.0 (the "License").
44
# You may not use this file except in compliance with the License.
55
# A copy of the License is located at
6-
#
6+
#
77
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# or in the "license" file accompanying this file. This file is distributed
10-
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11-
# express or implied. See the License for the specific language governing
8+
#
9+
# or in the "license" file accompanying this file. This file is distributed
10+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
# express or implied. See the License for the specific language governing
1212
# permissions and limitations under the License.
1313

1414
import pytest

0 commit comments

Comments
 (0)