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

Bug - [InferenceClient] - use proxy set in var env #2421

Merged

Conversation

morgandiverrez
Copy link
Contributor

@morgandiverrez morgandiverrez commented Jul 25, 2024

The AsyncInferenceClient doesn't use proxies set in environment variables.
It uses aiohttp but doesn't set the trust_env parameter to True.

this PR handle trust_env parameter to and set aiohttp client and request client
issue : AsyncInferenceClient doesn't use proxies set in environment variables #2420

@morgandiverrez morgandiverrez marked this pull request as draft July 25, 2024 10:01
@morgandiverrez morgandiverrez changed the title Bug - [AsyncInferenceClient] - use proxy set in var env Bug - [InferenceClient] - use proxy set in var env Jul 25, 2024
@morgandiverrez morgandiverrez marked this pull request as ready for review July 26, 2024 13:09
@morgandiverrez morgandiverrez marked this pull request as draft July 26, 2024 13:09
@morgandiverrez morgandiverrez marked this pull request as ready for review July 26, 2024 13:21
@morgandiverrez morgandiverrez force-pushed the AsyncInferenceClient-get-var-env-proxies branch from c281750 to 328b7a2 Compare July 31, 2024 07:43
Copy link
Contributor

@Benvii Benvii left a comment

Choose a reason for hiding this comment

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

Prevent the breaking change for aiohttp default trust_env is False see my suggestion

src/huggingface_hub/inference/_generated/_async_client.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Benvii Benvii left a comment

Choose a reason for hiding this comment

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

Thanks @morgandiverrez, looks good to me 👍️.

I saw that @Wauplin worked on this files a few weeks ago, thanks in advance for taking a look at this small PR.
Really helpful fix for those working under corporate proxy that want to take advantage of existing environment variables.

@morgandiverrez morgandiverrez force-pushed the AsyncInferenceClient-get-var-env-proxies branch from 244bb2a to 2ee0fb6 Compare August 4, 2024 08:55
@morgandiverrez
Copy link
Contributor Author

hello @severo @XciD , is it possible to taking a look at this small PR, it's really helpful fix

@Wauplin
Copy link
Contributor

Wauplin commented Aug 13, 2024

@morgandiverrez @Benvii thanks for the PR and your inputs and sorry for the delay! I'm having a look at it right now :)

@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.

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

@morgandiverrez I hope you don't mind, I pushed commits to your PR. Changing stuff in AsyncClientInference without changing InferenceClient is a bit more complex/annoying as it requires to update a generating script. Anyway, now we should have something good. I didn't want to add trust_env to InferenceClient since this PR is mostly about AsyncInferenceClient.

New commits:

  • Do not modify InferenceClient 263d64b
  • Add trust_env parameter + respect it in AsyncInferenceClient 15ba44a (also updating the generation script)
  • (misc) add docstring + clean newlines cd47edb 392e96e

Once the CI is green, I think we'll be good to merge.

@Wauplin
Copy link
Contributor

Wauplin commented Aug 13, 2024

Failing tests are unrelated so let's merge this :)

@Wauplin Wauplin merged commit c9c39b8 into huggingface:main Aug 13, 2024
12 of 14 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.

4 participants