File size: 474 Bytes
951f760
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python3
from __future__ import annotations

from pathlib import Path


def checkpoint_candidates(cache_dir: Path) -> list[Path]:
    return [
        cache_dir / "best_bpb.pt",
        cache_dir / "pretrain_final.pt",
        cache_dir / "latest.pt",
    ]


def choose_checkpoint_candidate(cache_dir: Path) -> Path | None:
    for path in checkpoint_candidates(cache_dir):
        if path.exists():
            return path
    return None