from pathlib import Path


def get_last_pretrained_weight_path(models_dir: Path) -> Path:
    """Get last pretrained weight path

    Args:
        models_dir (Path): directory, where model is stored

    Raises:
        FileNotFoundError: if no weights for model

    Returns:
        Path: weight's path
    """
    weights_dir = models_dir / 'weights'
    weights = list(weights_dir.glob('**/*.pt'))
    if not weights:
        raise FileNotFoundError(f"No weights here: {weights_dir}")
    last_weight = sorted(weights)[-1]
    return last_weight