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