tmp -> rename so a crash mid-write never corrupts the checkpoint.
(state, path)
| 57 | |
| 58 | |
| 59 | def _atomic_save(state, path): |
| 60 | """tmp -> rename so a crash mid-write never corrupts the checkpoint.""" |
| 61 | os.makedirs(os.path.dirname(path), exist_ok=True) |
| 62 | tmp = f"{path}.tmp" |
| 63 | torch.save(state, tmp) |
| 64 | os.replace(tmp, path) |
| 65 | |
| 66 | |
| 67 | class RunLogger: |
no outgoing calls
no test coverage detected