-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Remove requests code
#42845
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
base: main
Are you sure you want to change the base?
Remove requests code
#42845
Conversation
|
Hello, I got some issues with the current port to httpx. One way to do it would be for example: This also concerns some other portions of code (like |
|
Agree with @guibruand 's suggestion here! It's best to use |
Got it. I'll try using that and let you know! |
|
Thank you very much! 🤗 |
|
Hey @Wauplin , so I've used Thanks |
Wauplin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @omkar-334 , thanks for the changes and sorry for the delay before reviewing. I'm very sorry about my previous comment regarding get_session. I should have more carefully double-checked the changes and context before answering. It turns out most (if not all) changes made in the PR would better benefit from using httpx directly for simplicity rather than huggingface_hub.get_session.
While get_session is better suited to make requests to the Hub (it has HF-specific features), plain httpx is better suited for generic cases that are not HF-related. Also, let's use httpx in all 1-file scripts and utilities (since they are mostly meant for devs/maintainers rather than end users).
Sorry again about this change of direction 🙏
| import requests | ||
| import tensorflow as tf | ||
| import torch | ||
| from huggingface_hub import get_session |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above (and sorry not being explicit before). For single-file scripts I think it's best to keep it as lean as possible, i.e. use httpx directly as replacement of requests.
get_session is useful when calling the Hub. It adds features to handle request ids and manage offline mode. When in doubt you can use get_session but otherwise keep httpx for light calls to "generic endpoints" (like here, loading an image from the internet).
|
hey @Wauplin , went through your comments, understood the changes i need to make. Thanks for clarifying this.
Will make the changes and push soon... |
|
[For maintainers] Suggested jobs to run (before merge) run-slow: align, beit, bit, blip, blip_2, chameleon, clipseg, conditional_detr, convnext, convnextv2, d_fine, deformable_detr, deit, depth_anything, detr, dinov2 |
|
hey @Wauplin , I've made the changes.
Thanks! |
What does this PR do?
Removes
requestscode from setup, src and utils files.Fixes #42817 partially
make fixuppasses with no errorscc @CoderTCY @Wauplin @Rocketknight1
notes -
requestsfrom setup/workflow files as well, you might want to check the first commit.