docstr: Test that repeated save/restore never reuses same checkpoint dir.
docstr_tok: ["Test","that","repeated","save\/restore","never","reuses","same","checkpoint","dir","."]
code: def testCheckpointReuse(self):
      """Test that repeated save/restore never reuses same checkpoint dir."""
  
      def train_fn(config):
          checkpoint = ray.train.get_checkpoint()
          if checkpoint:
              with checkpoint.as_directory() as checkpoint_dir:
                  count = sum(
                      "checkpoint-" in path
                      for path in os.listdir(checkpoint_dir)
                  )
                  assert count == 1, os.listdir(checkpoint_dir)
  
          for step in range(20):
              with tempfile.TemporaryDirectory() as temp_checkpoint_dir:
                  path = os.path.join(
                      temp_checkpoint_dir, "checkpoint-{}".format(step)
                  )
                  open(path, "a").close()
                  ray.train.report(
                      dict(test=step),
                      checkpoint=Checkpoint.from_directory(
                          temp_checkpoint_dir
                      ),
                  )
  
      checkpoint = None
      for i in range(5):
          new_trainable = self.create_trainable(train_fn)
          if checkpoint:
              new_trainable.restore(checkpoint)
          for i in range(2):
              result = new_trainable.train()
          checkpoint = new_trainable.save()
          new_trainable.stop()
      assert result[TRAINING_ITERATION] == 10
  
imports: import json
  import os
  import sys
  import shutil
  import tempfile
  import unittest
  import ray
  from ray.air.constants import TRAINING_ITERATION
  from ray.rllib import _register_all
  import ray.train
  from ray import tune
  from ray.train import Checkpoint, CheckpointConfig
  from ray.tune.logger import NoopLogger
  from ray.tune.execution.placement_groups import PlacementGroupFactory
  from ray.tune.trainable import with_parameters, wrap_function
  from ray.tune.result import DEFAULT_METRIC
  from ray.tune.schedulers import ResourceChangingScheduler
  from ray.train.tests.util import mock_storage_context
label_desc: Use image node_id 4 for calling the FunctionCheckpointingTest obj's underlying member method code with example usage: obj.testCheckpointReuse() without return types