def latest_checkpoint()

in jcm/checkpoints.py [0:0]


def latest_checkpoint(ckpt_dir, prefix="checkpoint_"):
    """Retrieve the path of the latest checkpoint in a directory.

    Args:
      ckpt_dir: str: directory of checkpoints to restore from.
      prefix: str: name prefix of checkpoint files.

    Returns:
      The latest checkpoint path or None if no checkpoints were found.
    """
    glob_path = os.path.join(ckpt_dir, f"{prefix}*")
    checkpoint_files = natural_sort(blobfile.glob(glob_path))
    ckpt_tmp_path = _checkpoint_path(ckpt_dir, "tmp", prefix)
    checkpoint_files = [f for f in checkpoint_files if f != ckpt_tmp_path]
    if checkpoint_files:
        return checkpoint_files[-1]
    else:
        return None