from tensorflow.python.platform import gfile

      self.assertFalse(gfile.Exists(save._MetaGraphFilename(s1)))
      self.assertEqual(2, len(gfile.Glob(s2)))
      self.assertTrue(gfile.Exists(save._MetaGraphFilename(s2)))
      self.assertEqual(2, len(gfile.Glob(s3)))
      self.assertTrue(gfile.Exists(save._MetaGraphFilename(s3)))


class KeepCheckpointEveryNHoursTest(tf.test.TestCase):

  def testNonSharded(self):
    save_dir = os.path.join(self.get_temp_dir(),
                            "keep_checkpoint_every_n_hours")
    try:
      gfile.DeleteRecursively(save_dir)
    except OSError:
      pass                      # Ignore
    gfile.MakeDirs(save_dir)

    with self.test_session() as sess:
      v = tf.Variable([10.0], name="v")
      # Run the initializer NOW to avoid the 0.5s overhead of the first Run()
      # call, which throws the test timing off in fastbuild mode.
      tf.initialize_all_variables().run()
      # Create a saver that will keep the last 2 checkpoints plus one every 0.7
      # seconds.
      start_time = time.time()
