Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong path separator in error message when saved model does not exist #44741

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion tensorflow/python/saved_model/loader_impl.py
Expand Up @@ -108,8 +108,9 @@ def parse_saved_model(export_dir):
except text_format.ParseError as e:
raise IOError("Cannot parse file %s: %s." % (path_to_pbtxt, str(e)))
else:
raise IOError("SavedModel file does not exist at: %s/{%s|%s}" %
raise IOError("SavedModel file does not exist at: %s%s{%s|%s}" %
(export_dir,
os.path.sep,
constants.SAVED_MODEL_FILENAME_PBTXT,
constants.SAVED_MODEL_FILENAME_PB))

Expand Down
7 changes: 7 additions & 0 deletions tensorflow/python/saved_model/loader_test.py
Expand Up @@ -290,6 +290,13 @@ def test_load_saved_model_graph_with_return_elements(self, builder_cls):
with self.assertRaisesRegex(ValueError, "not found in graph"):
loader.load_graph(graph, ["foo_graph"], return_elements=["z:0"])

def test_parse_saved_model_exception(self, builder_cls):
"""Test that error message for not exist model have OS-depend delimiter in path"""
path = _get_export_dir("not_existing_dir")
pattern = os.path.sep + "{"
with self.assertRaises(IOError) as err:
loader_impl.parse_saved_model(path)
self.assertTrue(pattern in str(err.exception))
spopovru marked this conversation as resolved.
Show resolved Hide resolved

if __name__ == "__main__":
test.main()