Skip to content

Conversation

@luaenrique
Copy link
Contributor

What does this PR do?

This PR fixes an issue in run_clm_no_trainer.py where the .gitignore file was being truncated due to the use of "w+" mode when writing.
Now, the script preserves existing .gitignore content, avoids duplicates, and safely appends the required ignore patterns for model outputs (step_* and epoch_*).

I have tested with:

  1. no gitignore: file was created and populated with step_* and epoch_*
  2. gitignore with additional content: step_* and epoch_* were added after previous content
  3. blank gitignore: step_* and epoch_* were added to the file

Fixes #41896

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?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

wdyt @Rocketknight1?

Copy link
Member

@Rocketknight1 Rocketknight1 left a comment

Choose a reason for hiding this comment

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

Yes, nice fix! This looks like it actually does what the original code was supposed to do. Thank you!

@Rocketknight1 Rocketknight1 force-pushed the fix/gitignore-truncation branch from 569efb0 to 07a3a3b Compare October 31, 2025 12:08
@Rocketknight1 Rocketknight1 enabled auto-merge (squash) October 31, 2025 12:08
@Rocketknight1 Rocketknight1 merged commit 0a8ab33 into huggingface:main Oct 31, 2025
15 checks passed
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@luaenrique
Copy link
Contributor Author

Thanks @Rocketknight1!

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.

Issues when updating the .gitignore file in run_clm_no_trainer.py

3 participants