Fix python3 failures caused by change 145590579.
Change: 146063650
This commit is contained in:
parent
2bee7a66b5
commit
35b8855146
tensorflow
@ -183,7 +183,7 @@ class SaveRestoreShardedTest(test.TestCase):
|
||||
global_step, constants.ASSETS_DIRECTORY,
|
||||
"hello42.txt")
|
||||
asset_contents = gfile.GFile(assets_path).read()
|
||||
self.assertEqual(asset_contents, b"your data here")
|
||||
self.assertEqual(asset_contents, "your data here")
|
||||
self.assertEquals("hello42.txt", asset.filename)
|
||||
self.assertEquals("filename42:0", asset.tensor_binding.tensor_name)
|
||||
ignored_asset_path = os.path.join(export_path,
|
||||
|
@ -82,7 +82,7 @@ def load_session_bundle_from_path(export_dir,
|
||||
# Reads meta graph file.
|
||||
meta_graph_def = meta_graph_pb2.MetaGraphDef()
|
||||
meta_graph_def.ParseFromString(
|
||||
file_io.read_file_to_string(meta_graph_filename))
|
||||
file_io.read_file_to_string(meta_graph_filename, binary_mode=True))
|
||||
|
||||
variables_filename = ""
|
||||
variables_filename_list = []
|
||||
|
@ -228,20 +228,25 @@ def delete_file(filename):
|
||||
pywrap_tensorflow.DeleteFile(compat.as_bytes(filename), status)
|
||||
|
||||
|
||||
def read_file_to_string(filename):
|
||||
def read_file_to_string(filename, binary_mode=False):
|
||||
"""Reads the entire contents of a file to a string.
|
||||
|
||||
Args:
|
||||
filename: string, path to a file
|
||||
binary_mode: whether to open the file in binary mode or not. This changes
|
||||
the type of the object returned.
|
||||
|
||||
Returns:
|
||||
contents of the file as a string
|
||||
contents of the file as a string or bytes.
|
||||
|
||||
Raises:
|
||||
errors.OpError: Raises variety of errors that are subtypes e.g.
|
||||
NotFoundError etc.
|
||||
"""
|
||||
f = FileIO(filename, mode="r")
|
||||
if binary_mode:
|
||||
f = FileIO(filename, mode="rb")
|
||||
else:
|
||||
f = FileIO(filename, mode="r")
|
||||
return f.read()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user