class_docstr: Checkpoint manager that handles checkpoint book-keeping for a trial.
  
  The main purpose of this abstraction is to keep the top K checkpoints based on
  recency/a user-provided metric.
  
  NOTE: This class interacts with `_TrainingResult` objects, which are
  (checkpoint, metrics) pairs. This is to order checkpoints by metrics.
  
  Args:
      checkpoint_config: Defines how many and which checkpoints to keep.
class_docstr_tok: ["Checkpoint","manager","that","handles","checkpoint","book-keeping","for","a","trial",".","The","main","purpose","of","this","abstraction","is","to","keep","the","top","K","checkpoints","based","on","recency\/a","user-provided","metric",".","NOTE",":","This","class","interacts","with","`","_TrainingResult","`","objects",",","which","are","(","checkpoint",",","metrics",")","pairs",".","This","is","to","order","checkpoints","by","metrics",".","Args",":","checkpoint_config",":","Defines","how","many","and","which","checkpoints","to","keep","."]
docstr: Register new checkpoint and add to bookkeeping.
  
  This method will register a new checkpoint and add it to the internal
  bookkeeping logic. This means the checkpoint manager will decide if
  this checkpoint should be kept, and if older or worse performing
  checkpoints should be deleted.
  
  Args:
      checkpoint: Tracked checkpoint object to add to bookkeeping.
docstr_tok: ["Register","new","checkpoint","and","add","to","bookkeeping",".","This","method","will","register","a","new","checkpoint","and","add","it","to","the","internal","bookkeeping","logic",".","This","means","the","checkpoint","manager","will","decide","if","this","checkpoint","should","be","kept",",","and","if","older","or","worse","performing","checkpoints","should","be","deleted",".","Args",":","checkpoint",":","Tracked","checkpoint","object","to","add","to","bookkeeping","."]
code: def register_checkpoint(self, checkpoint_result: _TrainingResult):
      """Register new checkpoint and add to bookkeeping.
  
      This method will register a new checkpoint and add it to the internal
      bookkeeping logic. This means the checkpoint manager will decide if
      this checkpoint should be kept, and if older or worse performing
      checkpoints should be deleted.
  
      Args:
          checkpoint: Tracked checkpoint object to add to bookkeeping.
      """
      self._latest_checkpoint_result = checkpoint_result
  
      if self._checkpoint_config.checkpoint_score_attribute is not None:
          # If we're ordering by a score, insert the checkpoint
          # so that the list remains sorted.
          _insert_into_sorted_list(
              self._checkpoint_results,
              checkpoint_result,
              key=self._get_checkpoint_score,
          )
      else:
          # If no metric is provided, just append (ordering by time of registration).
          self._checkpoint_results.append(checkpoint_result)
  
      if self._checkpoint_config.num_to_keep is not None:
          # Delete the bottom (N - K) checkpoints
          worst_results = set(
              self._checkpoint_results[
                  : -self._checkpoint_config.num_to_keep
              ]
          )
          # Except for the latest checkpoint.
          results_to_delete = worst_results - {
              self._latest_checkpoint_result
          }
  
          # Update internal state before actually deleting them.
          self._checkpoint_results = [
              checkpoint_result
              for checkpoint_result in self._checkpoint_results
              if checkpoint_result not in results_to_delete
          ]
  
          for checkpoint_result in results_to_delete:
              checkpoint = checkpoint_result.checkpoint
              logger.debug("Deleting checkpoint: ", checkpoint)
              _delete_fs_path(
                  fs=checkpoint.filesystem, fs_path=checkpoint.path
              )
  
file_path: ray/python/ray/train/_internal/checkpoint_manager.py
imports: import logging
  import numbers
  from typing import Any, Callable, List, Optional, Tuple
  from ray._private.dict import flatten_dict
  from ray.air._internal.util import is_nan
  from ray.air.config import MAX
  from ray.train import CheckpointConfig
  from ray.train._internal.session import _TrainingResult
  from ray.train._internal.storage import _delete_fs_path
label_desc: Use image node_id 3 for calling the _CheckpointManager obj's underlying member method code with example usage: obj.register_checkpoint(checkpoint_result) without return types