| 134 | |
| 135 | |
| 136 | def get_latest_checkpoint(checkpoint_dir): |
| 137 | |
| 138 | # Get a list of all checkpoint files |
| 139 | checkpoint_files = glob.glob(os.path.join(checkpoint_dir, "*")) |
| 140 | # Check if there are any checkpoints |
| 141 | if not checkpoint_files: |
| 142 | # print("No checkpoints found") |
| 143 | # raise FileNotFoundError |
| 144 | return "No_checkpoints_found" |
| 145 | else: |
| 146 | # Get the checkpoint file with the latest modification time |
| 147 | latest_checkpoint = max(checkpoint_files, key=os.path.getmtime) |
| 148 | # print(f"Latest checkpoint: {latest_checkpoint}") |
| 149 | return latest_checkpoint |