diff --git a/smdebug/core/access_layer/file.py b/smdebug/core/access_layer/file.py index 8f373124a..940282f19 100644 --- a/smdebug/core/access_layer/file.py +++ b/smdebug/core/access_layer/file.py @@ -50,6 +50,11 @@ def close(self): """Close the file and move it from /tmp to a permanent directory.""" self._accessor.close() if self.mode in WRITE_MODES: + if not os.path.exists(self.temp_path): + self.logger.info( + f"Sagemaker-Debugger: Skipping close of file:{self.temp_path} as file doesn't exist" + ) + return shutil.move(self.temp_path, self.path) self.logger.debug( f"Sagemaker-Debugger: Wrote {os.path.getsize(self.path)} bytes to file {self.path}"