def get_all_checkpoints(dir: str, prefix: str = "model"):
    """
    Get a sorted list of all checkpoints found in directory.

    Args:
        dir (str): checkpoint directory
        prefix (str): common prefix among all checkpoints (without the final "-")

    Returns:
        list[(str, int)]: list of (name, step) sorted by step.
        Name is a checkpoint handle that can be passed to
        `tf.train.NewCheckpointReader` or :func:`load_checkpoint_vars`.
    """
    def step_from_filename(name):
        name = os.path.basename(name)
        name = name[len("{}-".format(prefix)):-len(".index")]
        return int(name)

    checkpoints = glob.glob(os.path.join(dir, "model-*.index"))
    checkpoints = [(f, step_from_filename(f)) for f in checkpoints]
    checkpoints = sorted(checkpoints, key=operator.itemgetter(1))
    return checkpoints

    Get a sorted list of all checkpoints found in directory.

    Args:
        dir (str): checkpoint directory
        prefix (str): common prefix among all checkpoints (without the final "-")

    Returns:
        list[(str, int)]: list of (name, step) sorted by step.
        Name is a checkpoint handle that can be passed to
        `tf.train.NewCheckpointReader` or :func:`load_checkpoint_vars`.
    
tensorpack/tfutils/varmanip.py