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

Commit b35ce3f

Browse files
committed
Correct encoding in file read/writes
1 parent c3b0c56 commit b35ce3f

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
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="utf-8")
2525
fd = f.fileno()
2626
fcntl.lockf(fd, fcntl.LOCK_EX)
2727

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="utf-8") 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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="utf-8") 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="utf-8") 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="utf-8") as f:
266266
template = f.read()
267267
if not template:
268268
raise ValueError("failed to read nginx.conf.template")

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="utf-8") as f:
224224
f.write(config)
225225

226226

0 commit comments

Comments
 (0)