MCPcopy Create free account
hub / github.com/rlcode/reinforcement-learning / _atomic_save

Function _atomic_save

4-atari-hard/env.py:59–64  ·  view source on GitHub ↗

tmp -> rename so a crash mid-write never corrupts the checkpoint.

(state, path)

Source from the content-addressed store, hash-verified

57
58
59def _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
67class RunLogger:

Callers 2

checkpointMethod · 0.70
finalizeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected