aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/training
diff options
context:
space:
mode:
authorGravatar Allen Lavoie <allenl@google.com>2018-08-24 16:17:28 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-24 16:23:04 -0700
commit58615322fd1fcdfffc78f1f57e284549f6f6ed6c (patch)
treeaf110c7029068d18d567b80261799dd96deb4d8e /tensorflow/python/training
parentf6c3c9733ed39f14ee3c32bc51ec62315b48ad31 (diff)
De-flake checkpoint_management_test
Modifies the clock by an epsilon to fix creation and instant reloads of CheckpointState. PiperOrigin-RevId: 210175050
Diffstat (limited to 'tensorflow/python/training')
-rw-r--r--tensorflow/python/training/checkpoint_management.py4
-rw-r--r--tensorflow/python/training/checkpoint_management_test.py3
2 files changed, 3 insertions, 4 deletions
diff --git a/tensorflow/python/training/checkpoint_management.py b/tensorflow/python/training/checkpoint_management.py
index b7aa8264b0..38910fb246 100644
--- a/tensorflow/python/training/checkpoint_management.py
+++ b/tensorflow/python/training/checkpoint_management.py
@@ -538,7 +538,9 @@ class CheckpointManager(object):
self._maybe_delete = collections.OrderedDict()
if recovered_state is None:
self._latest_checkpoint = None
- self._last_preserved_timestamp = current_clock
+ # Set the clock back slightly to avoid race conditions when quckly
+ # re-creating a CheckpointManager.
+ self._last_preserved_timestamp = current_clock - 1.
else:
self._latest_checkpoint = recovered_state.model_checkpoint_path
self._last_preserved_timestamp = recovered_state.last_preserved_timestamp
diff --git a/tensorflow/python/training/checkpoint_management_test.py b/tensorflow/python/training/checkpoint_management_test.py
index d7162265e6..8ef5048299 100644
--- a/tensorflow/python/training/checkpoint_management_test.py
+++ b/tensorflow/python/training/checkpoint_management_test.py
@@ -389,8 +389,6 @@ class CheckpointManagerTest(test.TestCase):
mock_time.time.return_value = first_time
first_manager.save()
state = checkpoint_management.get_checkpoint_state(directory)
- self.assertEqual([first_time], state.all_model_checkpoint_timestamps)
- self.assertEqual(3., state.last_preserved_timestamp)
second_time = first_time + 3610.
second_name = os.path.join(directory, "ckpt-2")
mock_time.time.return_value = second_time
@@ -398,7 +396,6 @@ class CheckpointManagerTest(test.TestCase):
state = checkpoint_management.get_checkpoint_state(directory)
self.assertEqual([first_time, second_time],
state.all_model_checkpoint_timestamps)
- self.assertEqual(3., state.last_preserved_timestamp)
self.assertEqual([first_name, second_name], first_manager.checkpoints)
self.assertEqual(second_name, first_manager.latest_checkpoint)
del first_manager