Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit e35158a

Browse files
Fix js_content duplicate error. Add encoding for file openings
1 parent ac6b43a commit e35158a

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

docker/build_artifacts/sagemaker/multi_model_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
@contextmanager
2323
def lock(path=DEFAULT_LOCK_FILE):
24-
f = open(path, "w")
24+
f = open(path, "w", encoding="utf8")
2525
fd = f.fileno()
2626
fcntl.lockf(fd, fcntl.LOCK_EX)
2727

docker/build_artifacts/sagemaker/nginx.conf.template

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,14 @@ http {
4444
}
4545

4646
location /ping {
47-
js_content tensorflowServing.ping;
4847
%FORWARD_PING_REQUESTS%;
4948
}
5049

5150
location /invocations {
52-
js_content tensorflowServing.invocations;
5351
%FORWARD_INVOCATION_REQUESTS%;
5452
}
5553

5654
location /models {
57-
js_content tensorflowServing.models;
5855
proxy_pass http://gunicorn_upstream/models;
5956
}
6057

@@ -65,9 +62,4 @@ http {
6562
keepalive_timeout 3;
6663
}
6764
}
68-
69-
export default {invocations, ping, ping_without_model, return_error,
70-
tfs_json_request, make_tfs_uri, parse_custom_attributes,
71-
json_request, is_tfs_json, is_json_lines, generic_json_request,
72-
json_lines_request, csv_request};
7365

docker/build_artifacts/sagemaker/python_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def _handle_load_model_post(self, res, data): # noqa: C901
150150
tfs_config_file = "/sagemaker/tfs-config/{}/model-config.cfg".format(model_name)
151151
log.info("tensorflow serving model config: \n%s\n", tfs_config)
152152
os.makedirs(os.path.dirname(tfs_config_file))
153-
with open(tfs_config_file, "w") as f:
153+
with open(tfs_config_file, "w", encoding="utf8") as f:
154154
f.write(tfs_config)
155155

156156
batching_config_file = "/sagemaker/batching/{}/batching-config.cfg".format(

docker/build_artifacts/sagemaker/serve.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
logging.basicConfig(level=logging.INFO)
2525
log = logging.getLogger(__name__)
2626

27-
JS_PING = "js_content ping"
28-
JS_INVOCATIONS = "js_content invocations"
27+
JS_PING = "js_content tensorflowServing.ping"
28+
JS_INVOCATIONS = "js_content tensorflowServing.invocations"
2929
GUNICORN_PING = "proxy_pass http://gunicorn_upstream/ping"
3030
GUNICORN_INVOCATIONS = "proxy_pass http://gunicorn_upstream/invocations"
3131
MULTI_MODEL = "s" if os.environ.get("SAGEMAKER_MULTI_MODEL", "False").lower() == "true" else ""
@@ -159,7 +159,7 @@ def _create_tfs_config(self):
159159

160160
log.info("tensorflow serving model config: \n%s\n", config)
161161

162-
with open(self._tfs_config_path, "w") as f:
162+
with open(self._tfs_config_path, "w", encoding="utf8") as f:
163163
f.write(config)
164164

165165
def _setup_gunicorn(self):
@@ -258,11 +258,11 @@ def _create_nginx_config(self):
258258
config = pattern.sub(lambda x: template_values[x.group(1)], template)
259259
log.info("nginx config: \n%s\n", config)
260260

261-
with open("/sagemaker/nginx.conf", "w") as f:
261+
with open("/sagemaker/nginx.conf", "w", encoding="utf8") as f:
262262
f.write(config)
263263

264264
def _read_nginx_template(self):
265-
with open("/sagemaker/nginx.conf.template", "r") as f:
265+
with open("/sagemaker/nginx.conf.template", "r", encoding="utf8") as f:
266266
template = f.read()
267267
if not template:
268268
raise ValueError("failed to read nginx.conf.template")

docker/build_artifacts/sagemaker/tensorflowServing.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,8 @@ function csv_request(r) {
232232
builder.push(']}')
233233
tfs_json_request(r, builder.join(''))
234234
}
235+
236+
export default {invocations, ping, ping_without_model, return_error,
237+
tfs_json_request, make_tfs_uri, parse_custom_attributes,
238+
json_request, is_tfs_json, is_json_lines, generic_json_request,
239+
json_lines_request, csv_request};

docker/build_artifacts/sagemaker/tfs_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def __init__(self, key, env_var, value, defaulted_message):
220220
config += "%s { value: %s }\n" % (batching_parameter.key, batching_parameter.value)
221221

222222
log.info("batching config: \n%s\n", config)
223-
with open(batching_config_file, "w") as f:
223+
with open(batching_config_file, "w", encoding="utf8") as f:
224224
f.write(config)
225225

226226

0 commit comments

Comments
 (0)