From 4b73d90bce17c8e553801306b7c56ec101946704 Mon Sep 17 00:00:00 2001 From: bghira Date: Fri, 6 Dec 2024 15:11:13 +0000 Subject: [PATCH] multigpu rename error masking --- helpers/data_backend/local.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/helpers/data_backend/local.py b/helpers/data_backend/local.py index 70abe4e2..5c7434cb 100644 --- a/helpers/data_backend/local.py +++ b/helpers/data_backend/local.py @@ -68,7 +68,10 @@ def write(self, filepath: str, data: Any) -> None: fcntl.flock(temp_file, fcntl.LOCK_UN) # Atomically replace the target file with the temporary file - os.rename(temp_file_path, filepath) + try: + os.rename(temp_file_path, filepath) + except FileNotFoundError: + pass def delete(self, filepath): @@ -258,7 +261,10 @@ def torch_save(self, data, original_location): # Release the lock fcntl.flock(temp_file, fcntl.LOCK_UN) # Atomically replace the target file with the temporary file - os.rename(temp_file_path, filepath) + try: + os.rename(temp_file_path, filepath) + except FileNotFoundError: + pass else: # Handle the case where original_location is a file object temp_file = original_location