fix: replace os.rename with shutil.move for cross-partition file moves #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request fixes an issue in the
SampleId.download_filefunction when saving a model checkpoint to a directory on a different partition from the root filesystem.Problem
On my system, the root volume
/is mounted on a different partition than/home, where the model checkpoint is saved. This caused the following error:Because the temporary file where the checkpoint is initially saved is on a different partition from its final destination.
Therefore, this error occurs when attempting to move a file across different filesystems using an operation that only works within a single filesystem.
Solution
Based on guidance from a related Stack Overflow discussion, operation that should be used is
shutil.move, which correctly handles moves across different partitions/filesystems.This change ensures that
SampleId.download_fileworks regardless of how the underlying filesystems are mounted.