diff options
author | Zongheng Yang <zongheng@google.com> | 2016-08-18 18:26:38 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-08-18 19:32:41 -0700 |
commit | d2c2a4d9e95527371520f7207f848c04a0ea3e9b (patch) | |
tree | a3f406d8fd065a4f3e8df0af509a55fc414e1bea | |
parent | ec81f62146e31b3f9f58158211fcd44a976b7197 (diff) |
Fix recent Saver breakage.
Note that all file I/O in TensorFlow should be done via gfile (or file_io in
the near future), instead of using os.path.
Change: 130710688
-rw-r--r-- | tensorflow/python/training/saver.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/tensorflow/python/training/saver.py b/tensorflow/python/training/saver.py index 24aebb23e4..b9694e0956 100644 --- a/tensorflow/python/training/saver.py +++ b/tensorflow/python/training/saver.py @@ -49,6 +49,7 @@ from tensorflow.python.ops import gen_io_ops from tensorflow.python.ops import io_ops from tensorflow.python.ops import state_ops from tensorflow.python.ops import variables +from tensorflow.python.platform import gfile from tensorflow.python.platform import tf_logging as logging from tensorflow.python.training import training_util from tensorflow.python.training.checkpoint_state_pb2 import CheckpointState @@ -1226,17 +1227,14 @@ class Saver(object): "'latest_filename' collides with 'save_path': '%s' and '%s'" % (latest_filename, save_path)) - if not os.path.exists(os.path.dirname(save_path)): - raise ValueError("Parent directory of {} doesn't exist, can't save.".format(save_path)) + if not gfile.IsDirectory(os.path.dirname(save_path)): + raise ValueError( + "Parent directory of {} doesn't exist, can't save.".format(save_path)) save_path = os.path.dirname(save_path) if not isinstance(sess, session.SessionInterface): raise TypeError("'sess' must be a Session; %s" % sess) - # Note a few lines above save_path was set to os.path.dirname(save_path) - if not os.path.exists(save_path): - raise ValueError("Parent directory {} doesn't exist, can't save.".format(save_path)) - model_checkpoint_path = sess.run( self.saver_def.save_tensor_name, {self.saver_def.filename_tensor_name: checkpoint_file}) |