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

update codecarbon #35243

Merged
merged 5 commits into from
Dec 20, 2024
Merged

update codecarbon #35243

merged 5 commits into from
Dec 20, 2024

Conversation

nhamanasu
Copy link
Contributor

What does this PR do?

  • Related to #390 Add Python 3.11 support mlco2/codecarbon#391, I found we need to update codecarbon to run test_trainer.py properly in Python 3.11 or above. In current main branch, "codecarbon==1.2.0" was set, so I rewrote this to "codecarbon>=2.8.1". It properly worked.
  • test_trainer.py generates some output directories which could be staged through git. I added them in .gitignore

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.

@nhamanasu
Copy link
Contributor Author

nhamanasu commented Dec 12, 2024

@Rocketknight1
Copy link
Member

cc @ydshieh @muellerzr @SunMarc

Copy link
Collaborator

@ydshieh ydshieh left a comment

Choose a reason for hiding this comment

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

LGTM (don't know the reason why it was pinned to 1.2.0 previously)

CircleCI jobs don't install codecarbon so no need to build and check before merge. We can see next dailiy CI next week.

Thanks

@ydshieh
Copy link
Collaborator

ydshieh commented Dec 13, 2024

will let at least one of @muellerzr or @SunMarc to approve too.

Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

LGTM ! Left a comment

.gitignore Outdated
Comment on lines 170 to 175

# folders generated in test_trainer.py
/test
/regression
/None
/examples/checkpoint-*
Copy link
Member

Choose a reason for hiding this comment

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

Do you know which test is causing this. ? We try to put everything that are saved in temp folder

Copy link
Contributor Author

@nhamanasu nhamanasu Dec 13, 2024

Choose a reason for hiding this comment

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

Thank you for your comment! Let me see...

I've searched the lines maybe related to:

".test"

args = TrainingArguments("./test", report_to="none")



"./test", learning_rate=1e9, logging_steps=5, logging_nan_inf_filter=False, report_to="none"

"./test", learning_rate=1e9, logging_steps=5, logging_nan_inf_filter=True, report_to="none"

args = TrainingArguments("./test", report_to="none", dataloader_persistent_workers=False)


"./regression":

output_dir = kwargs.pop("output_dir", "./regression")

args = TrainingArguments("./regression", learning_rate=0.1, report_to="none")

args = TrainingArguments("./regression", report_to="none")

"./examples"

training_args = TrainingArguments(output_dir="./examples", use_cpu=True, report_to="none")

output_dir="./examples",

args = RegressionTrainingArguments(output_dir="./examples", max_steps=4)

args = RegressionTrainingArguments(output_dir="./examples")

args = RegressionTrainingArguments(output_dir="./examples")

"./None"

I couldn't find any directly specified part, but I've seen "./None" folder is made every time I run test_trainer. I suspect that there are some lines which don't pass output_dir to TrainingArguments, or the variables passed to TrainingArguments are occasionally None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure all of these are the main cause, but when I ran test_trainer.py, it surely made the folders I wrote in .gitignore.

Copy link
Contributor Author

@nhamanasu nhamanasu Dec 13, 2024

Choose a reason for hiding this comment

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

I found 117 lines which use with tempfile.TemporaryDirectory() as tmp_dir: and pass tmp_dir to TrainingArguments, so most of the test experiments properly utilizes temp dir, and the lines I picked above seem to be irregular.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found another non-tmp-dir specified in test_trainer.py

"./generation"




@nhamanasu
Copy link
Contributor Author

I replaced "./test", "./examples", "./generation", and "./regression" with tmp_dir.

The only part left we need to find is the causes of producing "./None" dir, I think.

@nhamanasu
Copy link
Contributor Author

nhamanasu commented Dec 13, 2024

Maybe I did something unnecessary...

New failure FAILED tests/trainer/test_trainer.py::TrainerIntegrationWithHubTester::test_push_to_hub - AssertionError: '__DUMMY_TRANSFORMERS_USER__/tmpnlv7o37x' != '__DUMMY_TRANSFORMERS_USER__/tmp_mcwovml' may be related to the part I replaced.

Testing push_to_hub requires the checkpoint dir which is not temporary I guess?

I'm ready to revert the last commit and just leave .gitignore intact.

I want your review @SunMarc .

@ydshieh
Copy link
Collaborator

ydshieh commented Dec 13, 2024

Hi, the last commit of changing won't work as the tmp_dir is created within the scope of

    with tempfile.TemporaryDirectory() as tmp_dir:

outside the with block, the directory is removed automatically and the sequential code blocks won't be able to access it.

@nhamanasu
Copy link
Contributor Author

It's my trivial mistake. Thank you for pointing it out.
I'll fix them.

@ydshieh
Copy link
Collaborator

ydshieh commented Dec 13, 2024

I guess it's good to just revert that commit , keep this PR as doing what it intends to do. For the temp. directory, we can address them in another PR (if eventually we really wish )

@nhamanasu
Copy link
Contributor Author

nhamanasu commented Dec 13, 2024

Thank you for your comments! I reverted the last commit, and gonna make another PR to fix tmp_dir issue.

→ I split the PR as @ydshieh suggested: #35266

.gitignore Outdated
Comment on lines 170 to 175

# folders generated in test_trainer.py
/test
/regression
/None
/examples/checkpoint-*
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's also revert this one in this PR :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I reverted it!

.gitignore Outdated Show resolved Hide resolved
@nhamanasu
Copy link
Contributor Author

@ydshieh cc. @SunMarc
Thank you for your last commit to fix .gitignore!

I wonder what kind of step is left to finally merge this PR.
If there's something l still have to do, I'd be happy if you could let me know 🙇

@ydshieh ydshieh requested a review from ArthurZucker December 16, 2024 09:25
@ydshieh
Copy link
Collaborator

ydshieh commented Dec 16, 2024

@ArthurZucker We need an approval from you :-) 🙏

Copy link
Collaborator

@ArthurZucker ArthurZucker 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 the update! 🤗

@ArthurZucker ArthurZucker merged commit 34ad1bd into huggingface:main Dec 20, 2024
22 checks passed
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.

5 participants