We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ea7e9a9 commit ecb4800Copy full SHA for ecb4800
src/sagemaker/serializers.py
@@ -18,7 +18,6 @@
18
import csv
19
import io
20
import json
21
-import os
22
import numpy as np
23
from six import with_metaclass
24
@@ -381,10 +380,13 @@ def serialize(self, data):
381
380
raw-bytes: The data serialized as a raw-bytes from the input.
382
"""
383
if isinstance(data, str):
384
- if not os.path.exists(data):
+ try:
+ dataFile = open(data, "rb")
385
+ except Exception:
386
raise ValueError(f"{data} is not a valid file path.")
- image = open(data, "rb")
387
- return image.read()
+ dataFileInfo = dataFile.read()
388
+ dataFile.close()
389
+ return dataFileInfo
390
if isinstance(data, bytes):
391
return data
392
0 commit comments