Skip to content

Commit eed6b4c

Browse files
authored
check file exist before moving (aws#364)
* check file exist before moving when closing the file.
1 parent e20495b commit eed6b4c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

smdebug/core/access_layer/file.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ def close(self):
5050
"""Close the file and move it from /tmp to a permanent directory."""
5151
self._accessor.close()
5252
if self.mode in WRITE_MODES:
53+
if not os.path.exists(self.temp_path):
54+
self.logger.info(
55+
f"Sagemaker-Debugger: Skipping close of file:{self.temp_path} as file doesn't exist"
56+
)
57+
return
5358
shutil.move(self.temp_path, self.path)
5459
self.logger.debug(
5560
f"Sagemaker-Debugger: Wrote {os.path.getsize(self.path)} bytes to file {self.path}"

0 commit comments

Comments
 (0)