Skip to content

Migrate httpx imports through huggingface_hub - #4003

Merged
tomaarsen merged 2 commits into
huggingface:mainfrom
Wauplin:fix/httpx-hub-imports
Sep 11, 2026
Merged

tomaarsen merged 2 commits into
huggingface:mainfrom
Wauplin:fix/httpx-hub-imports

Conversation

@Wauplin

@Wauplin Wauplin commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Direct httpx imports will break when huggingface_hub migrates to httpx2. Import through huggingface_hub.utils instead, using the compatibility export shipped in huggingface_hub 1.31.0. Goal is to make sentence-transformers compatible with both huggingface_hub 1.x and 2.x when the switch to httpx2 happens.

Related: huggingface/huggingface_hub#4803 and huggingface/huggingface_hub#4802.

@Wauplin
Wauplin marked this pull request as ready for review September 10, 2026 15:55
@tomaarsen

Copy link
Copy Markdown
Member

Thanks! I pushed a small follow-up to preserve the >=1.3.0 lower bound and widen the upper bound to <3.0.0. We now try the Hub’s httpx export first, falling back to a direct import for older Hub versions. As far as I can tell, this should be safe for users of modern/future hf_hub versions, while also allowing people to stick with older hf_hub versions if they're bottlenecked by some other dependencies. I like to keep my versions as wide as possible to avoid being a pain in people's collective asses.

  • Tom Aarsen

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Update the migration guide so its documented Hub support range matches the package metadata.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates HTTP imports through huggingface_hub for compatibility with Hub 1.x and 2.x.

Changes:

  • Adds a compatibility import with fallback support.
  • Updates file I/O tests to use it.
  • Allows huggingface-hub versions below 3.0.0.
File summaries
File Summary
tests/util/test_file_io.py Uses the compatibility HTTP client in tests.
sentence_transformers/util/file_io.py Routes HTTP imports through huggingface_hub.
pyproject.toml Expands the Hub dependency range to include 2.x; migration guidance also needs updating.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pyproject.toml Resolved
@tomaarsen
tomaarsen merged commit 63b6a0d into huggingface:main Sep 11, 2026
10 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.

3 participants