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

Don't push checkpoints to hub in no_trainer scripts #16703

Merged
merged 5 commits into from
Apr 11, 2022

Conversation

muellerzr
Copy link
Contributor

Don't push checkpoints to the Hub in no_trainer scripts

What does this add?

  • Creates a gitignore file in the base folder if push_to_hub was passed and one does not exist
  • During each call to save_state, if push_to_hub was passed then then directory is added to the .gitignore

Why is it needed?

Users shouldn't expect to have all of their checkpoints sent to both the Hub and saved locally, it should just be locally until they are ready for the final save

@muellerzr muellerzr requested a review from sgugger April 11, 2022 15:37
@muellerzr muellerzr changed the title PyTorch Don't push checkpoints to hub in no_trainer scripts Apr 11, 2022
@muellerzr muellerzr added PyTorch Anything PyTorch External Using the library with external tools (onnx, tflite, ...) Examples Which is related to examples in general labels Apr 11, 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.

I think we can just set the gitignore with a general pattern at its creation.

Comment on lines 262 to 263
if not os.path.exists(gitignore_path):
open(gitignore_path, "a").close() # Creates a .gitignore
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd directly put here the step-* key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yeah that would be a bit more simplistic. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simplified it to:

            with open(os.path.join(args.output_dir, ".gitignore"), 'w+') as gitignore:
                if "step_*" not in gitignore:
                    gitignore.write("step_*\n")
                if "epoch_*" not in gitignore:
                    gitignore.write("epoch_*\n")

Since we can have both epoch_ and step_

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice!

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 11, 2022

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

@muellerzr muellerzr requested a review from sgugger April 11, 2022 16:25
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.

Thanks for working on this!

@muellerzr muellerzr merged commit d4b3e35 into main Apr 11, 2022
@muellerzr muellerzr deleted the muellerzr-no_trainer-bugfix branch April 11, 2022 16:42
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
)

Adds checkpoint prefixes to the gitignore if `push_to_hub` is used along with `checkpointint_steps`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Examples Which is related to examples in general External Using the library with external tools (onnx, tflite, ...) PyTorch Anything PyTorch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants