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

Fix RequestCounter to make it more future-proof #27406

Merged
merged 2 commits into from
Nov 9, 2023
Merged

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Nov 9, 2023

Related to #27389 and #27393 (cc @amyeroberts @ydshieh).

The problem came from the fact that transformers test suite was trying to mock huggingface_hub.utils.get_session which is an internal method that I sometimes move/adapt for my needs. It shouldn't change much in the future but to make it more future-proof I chose to intercept the urllib3 debug logs directly. It's not perfect as urllib3 might change their logs + we could use pytest.caplog instead but at this stage I think we are fine.

I also unskipped the 2 tests that were previously failing.

Copy link
Collaborator

@amyeroberts amyeroberts 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 fixing!

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Nov 9, 2023

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

self.assertEqual(counter.other_request_count, 0)
self.assertEqual(counter["GET"], 0)
self.assertEqual(counter["HEAD"], 1)
self.assertEqual(counter.total_calls, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIRC, this means no other request, so we are good as before, right (i.e. no extra requests)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep exactly! I'm counting all request types separately :)

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.

I need to learn more python, but don't want to block this PR. Thank you @Wauplin for the fix. Just a tiny question

@ydshieh
Copy link
Collaborator

ydshieh commented Nov 9, 2023

I will merge once something on main is fixed. (should be soon)

@ydshieh ydshieh merged commit e38348a into main Nov 9, 2023
18 of 20 checks passed
@ydshieh ydshieh deleted the fix-mock-request-counter branch November 9, 2023 17:53
EduardoPach pushed a commit to EduardoPach/transformers that referenced this pull request Nov 19, 2023
* Fix RequestCounter to make it more future-proof

* code quality
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.

4 participants