tidy(nodes): do not refer to files as latents in PickleStorageTorch (again)

This commit is contained in:
psychedelicious 2024-02-07 18:44:30 +11:00
parent fd30cb4d90
commit 25386a76ef

View File

@ -25,17 +25,17 @@ class PickleStorageTorch(PickleStorageBase[T]):
self._delete_all_items() self._delete_all_items()
def get(self, name: str) -> T: def get(self, name: str) -> T:
latent_path = self._get_path(name) file_path = self._get_path(name)
return torch.load(latent_path) return torch.load(file_path)
def save(self, name: str, data: T) -> None: def save(self, name: str, data: T) -> None:
self._output_folder.mkdir(parents=True, exist_ok=True) self._output_folder.mkdir(parents=True, exist_ok=True)
latent_path = self._get_path(name) file_path = self._get_path(name)
torch.save(data, latent_path) torch.save(data, file_path)
def delete(self, name: str) -> None: def delete(self, name: str) -> None:
latent_path = self._get_path(name) file_path = self._get_path(name)
latent_path.unlink() file_path.unlink()
def _get_path(self, name: str) -> Path: def _get_path(self, name: str) -> Path:
return self._output_folder / name return self._output_folder / name