original_docstring: Test only recent retention policy when there's pre-emptions.
docstring: Test only recent retention policy when there's pre-emptions.
docstring_tokens: Test only recent retention policy when there ' s pre - emptions .
code: def testRecentOnlyPreempt(self):
      """Test only recent retention policy when there's pre-emptions."""
      logdir = tempfile.mkdtemp()
      g, sav, inc = self._buildGraphAndSaver(
          logdir, keep_latest_n=5, keep_every_n_hours=None)
      with self.session(graph=g) as sess:
        # Creates a few checkpoints.
        sess.run(tf.global_variables_initializer())
        for _ in range(5):
          sess.run(inc)
          _ = sav.Save(sess)
  
        # Restore to the latest.
        sess.run(tf.global_variables_initializer())
        _ = sav.Restore(sess)
  
      # Simulate a pre-emption, create a brand new graph/saver.
      g, sav, inc = self._buildGraphAndSaver(
          logdir, keep_latest_n=5, keep_every_n_hours=None)
      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)
  
      ckpt_ids = self._checkpointIds(logdir)
      # Expect only the most recent 5.
      self.assertEqual([5, 6, 7, 8, 9], ckpt_ids)
code_tokens: def testRecentOnlyPreempt ( self ) : logdir = tempfile . mkdtemp ( ) g , sav , inc = self . _buildGraphAndSaver ( logdir , keep_latest_n = 5 , keep_every_n_hours = None ) with self . session ( graph = g ) as sess : sess . run ( tf . global_variables_initializer ( ) ) for _ in range ( 5 ) : sess . run ( inc ) _ = sav . Save ( sess ) sess . run ( tf . global_variables_initializer ( ) ) _ = sav . Restore ( sess ) g , sav , inc = self . _buildGraphAndSaver ( logdir , keep_latest_n = 5 , keep_every_n_hours = None ) 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 ) ckpt_ids = self . _checkpointIds ( logdir ) self . assertEqual ( [ 5 , 6 , 7 , 8 , 9 ] , ckpt_ids )
short_docstring: Test only recent retention policy when there's pre-emptions.
short_docstring_tokens: Test only recent retention policy when there ' s pre - emptions .
comment: """Test only recent retention policy when there's pre-emptions."""$SEP$# Creates a few checkpoints.$SEP$# Restore to the latest.$SEP$# Simulate a pre-emption, create a brand new graph/saver.$SEP$# Creates a few checkpoints.$SEP$# Expect only the most recent 5.