Fix: add directory existence check in find_largest_model to prevent FileNotFoundError on Windows

This commit is contained in:
Asatov Oybek 2026-03-09 22:41:10 +03:00
parent 1076f97059
commit d1fae8c1d5

View File

@ -116,6 +116,10 @@ def build_model(checkpoint_dir, step, device, phase):
def find_largest_model(checkpoints_dir):
# Check if the directory exists to prevent FileNotFoundError on Windows/Linux
if not os.path.exists(checkpoints_dir):
raise FileNotFoundError(f"Directory not found: {checkpoints_dir}. You may need to train a model first.")
# attempt to guess the model tag: take the biggest model available
model_tags = [f for f in os.listdir(checkpoints_dir) if os.path.isdir(os.path.join(checkpoints_dir, f))]
if not model_tags: