Method
_write_entry
(
self,
path: Path,
tensors: Dict[str, np.ndarray],
)
Source from the content-addressed store, hash-verified
| 12450 | ) |
| 12451 | |
| 12452 | def _write_entry( |
| 12453 | self, |
| 12454 | path: Path, |
| 12455 | tensors: Dict[str, np.ndarray], |
| 12456 | ) -> None: |
| 12457 | tmp_path = path.with_name(f"{path.name}.tmp") |
| 12458 | try: |
| 12459 | self._save_file(tensors, tmp_path, self._metadata) |
| 12460 | os.replace(tmp_path, path) |
| 12461 | except Exception: |
| 12462 | try: |
| 12463 | tmp_path.unlink() |
| 12464 | except FileNotFoundError: |
| 12465 | pass |
| 12466 | raise |
| 12467 | |
| 12468 | def _load_entries(self) -> None: |
| 12469 | for path in sorted(self.path.glob("*.safetensors")): |
Tested by
no test coverage detected