original_docstring: Test indefinite retention policy and recent policy.
docstring: Test indefinite retention policy and recent policy.
docstring_tokens: Test indefinite retention policy and recent policy .
code: def testBothPoliciesPreempt(self, mock_time):
      """Test indefinite retention policy and recent policy."""
      fake_time = time.time()
      mock_time.time.return_value = fake_time
      logdir = tempfile.mkdtemp()
      g, sav, inc = self._buildGraphAndSaver(
          logdir, keep_latest_n=2, keep_every_n_hours=5)
      with self.session(graph=g) as sess:
        # Creates a few checkpoints.
        sess.run(tf.global_variables_initializer())
        for _ in range(6):
          sess.run(inc)
          _ = sav.Save(sess)
          # Advance mock time one-ish hour.
          fake_time += 3601.0
          mock_time.time.return_value = fake_time
  
      fake_time += 100000.0
      mock_time.time.return_value = fake_time
  
      # Simulate a pre-emption, create a brand new graph/saver and run
      # a few steps.
      g, sav, inc = self._buildGraphAndSaver(
          logdir, keep_latest_n=2, keep_every_n_hours=5)
      with self.session(graph=g) as sess:
        # Creates a few checkpoints.
        sess.run(tf.global_variables_initializer())
        _ = sav.Restore(sess)
        for _ in range(4):
          sess.run(inc)
          _ = sav.Save(sess)
          fake_time += 3601.0
          mock_time.time.return_value = fake_time
  
      ckpt_ids = self._checkpointIds(logdir)
  
      # 1,6,7 are kept due to indefinite policy
      # 9,10 due to recent policy.
      self.assertEqual([1, 6, 7, 9, 10], ckpt_ids)
code_tokens: def testBothPoliciesPreempt ( self , mock_time ) : fake_time = time . time ( ) mock_time . time . return_value = fake_time logdir = tempfile . mkdtemp ( ) g , sav , inc = self . _buildGraphAndSaver ( logdir , keep_latest_n = 2 , keep_every_n_hours = 5 ) with self . session ( graph = g ) as sess : sess . run ( tf . global_variables_initializer ( ) ) for _ in range ( 6 ) : sess . run ( inc ) _ = sav . Save ( sess ) fake_time += 3601.0 mock_time . time . return_value = fake_time fake_time += 100000.0 mock_time . time . return_value = fake_time g , sav , inc = self . _buildGraphAndSaver ( logdir , keep_latest_n = 2 , keep_every_n_hours = 5 ) with self . session ( graph = g ) as sess : sess . run ( tf . global_variables_initializer ( ) ) _ = sav . Restore ( sess ) for _ in range ( 4 ) : sess . run ( inc ) _ = sav . Save ( sess ) fake_time += 3601.0 mock_time . time . return_value = fake_time ckpt_ids = self . _checkpointIds ( logdir ) self . assertEqual ( [ 1 , 6 , 7 , 9 , 10 ] , ckpt_ids )
short_docstring: Test indefinite retention policy and recent policy.
short_docstring_tokens: Test indefinite retention policy and recent policy .
comment: """Test indefinite retention policy and recent policy."""$SEP$# Creates a few checkpoints.$SEP$# Advance mock time one-ish hour.$SEP$# Simulate a pre-emption, create a brand new graph/saver and run$SEP$# a few steps.$SEP$# Creates a few checkpoints.$SEP$# 1,6,7 are kept due to indefinite policy$SEP$# 9,10 due to recent policy.