Download utils/checkpoint.py from ViuAI/Murli-V1.5-Code: direct link, hf CLI and curl.
- Browser
- Download file 475 Bytes
-
https://huggingface.co/ViuAI/Murli-V1.5-Code/resolve/main/utils/checkpoint.py
- Command line
-
hf download hf://ViuAI/Murli-V1.5-Code/utils/checkpoint.py
-
curl -L -o checkpoint.py https://huggingface.co/ViuAI/Murli-V1.5-Code/resolve/main/utils/checkpoint.py
475 Bytes
| """Atomic writes shared by checkpoints and feature caches.""" | |
| import os | |
| import tempfile | |
| from pathlib import Path | |
| import torch | |
| def atomic_save(payload, destination): | |
| destination = Path(destination) | |
| with tempfile.NamedTemporaryFile(dir=destination.parent, delete=False) as stream: | |
| temporary = stream.name | |
| try: | |
| torch.save(payload, temporary) | |
| os.replace(temporary, destination) | |
| finally: | |
| Path(temporary).unlink(missing_ok=True) | |