Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed crash when deleting older checkpoint and files with name f"{checkpoint_prefix}-*" exist #16686

Merged
merged 1 commit into from
Apr 11, 2022

Conversation

sadransh
Copy link
Contributor

@sadransh sadransh commented Apr 10, 2022

What does this PR do?

I create an archive of older checkpoints during training the checkpoint has a name with f"{checkpoint_prefix}-*.zip/.tar
previously glob(f"{checkpoint_prefix}-*") takes all files/folders starting with the name checkpoint, and later shutil.rmtree(checkpoint) takes a folder name; since at some point it my get a zip file; it crashes training; adding this if os.path.isdir(x) allows only folders on glob_checkpoints.

let's say output folder structure is like: (with save_limit=5)

checkpoint-36000
checkpoint-35000
checkpoint-34000
checkpoint-33000
checkpoint-33000.zip

then code attempts to remove oldest checkpoint
since we have a file (checkpoint-33000.zip) and pass the file to shutil.rmtree(checkpoint) to delete it will fail.

by avoiding storing files on glob_checkpoints this will get fixed! ( checking everything is folder as checkpoints are folders not single files.)

Before submitting:

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@sgugger

…refix}-*" exist

I create an archive of older checkpoints during training the checkpoint has a  name with `f"{checkpoint_prefix}-*.zip/.tar ` 
previously `glob(f"{checkpoint_prefix}-*")` takes all files/folders starting with the name checkpoint, and later `shutil.rmtree(checkpoint)` takes a folder name; since at some point it my get a zip file; it crashes training; adding this `if os.path.isdir(x)` allows only folders on `glob_checkpoints`
@sadransh sadransh changed the title fixed crash when deleting older checkpoint and a file f"{checkpoint_p… fixed crash when deleting older checkpoint and a file f"{checkpoint_prefix}-*" exist Apr 10, 2022
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 10, 2022

The documentation is not available anymore as the PR was closed or merged.

@sadransh
Copy link
Contributor Author

@sgugger

@sadransh sadransh changed the title fixed crash when deleting older checkpoint and a file f"{checkpoint_prefix}-*" exist fixed crash when deleting older checkpoint and a files with name f"{checkpoint_prefix}-*" exist Apr 10, 2022
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix! Thanks a lot!

@sgugger sgugger merged commit 6ef7186 into huggingface:main Apr 11, 2022
@sadransh sadransh changed the title fixed crash when deleting older checkpoint and a files with name f"{checkpoint_prefix}-*" exist fixed crash when deleting older checkpoint and files with name f"{checkpoint_prefix}-*" exist Apr 11, 2022
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
…refix}-*" exist (huggingface#16686)

I create an archive of older checkpoints during training the checkpoint has a  name with `f"{checkpoint_prefix}-*.zip/.tar ` 
previously `glob(f"{checkpoint_prefix}-*")` takes all files/folders starting with the name checkpoint, and later `shutil.rmtree(checkpoint)` takes a folder name; since at some point it my get a zip file; it crashes training; adding this `if os.path.isdir(x)` allows only folders on `glob_checkpoints`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants