(path)
| 21 | |
| 22 | |
| 23 | def get_latest_checkpoint_folder(path): |
| 24 | max_num = None |
| 25 | if not os.path.exists(path): |
| 26 | return max_num |
| 27 | for name in os.listdir(path): |
| 28 | folder_path = os.path.join(path, name) |
| 29 | if os.path.isdir(folder_path): |
| 30 | try: |
| 31 | num = int(name) |
| 32 | if max_num is None or num > max_num: |
| 33 | max_num = num |
| 34 | except ValueError: |
| 35 | pass # Skip non-numeric folder names |
| 36 | return max_num |
| 37 | |
| 38 | |
| 39 | class Checkpointer: |