Skip to content

toxgen: Add huggingface_hub #4299

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

Merged
merged 4 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8","3.9","3.11","3.12"]
python-version: ["3.8","3.9","3.10","3.11","3.12","3.13"]
# python3.6 reached EOL and is no longer being supported on
# new versions of hosted runners on Github Actions
# ubuntu-20.04 is the last version that supported python3.6
Expand Down
1 change: 0 additions & 1 deletion scripts/populate_tox/populate_tox.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"fastapi",
"gcp",
"httpx",
"huggingface_hub",
"langchain",
"langchain_notiktoken",
"openai",
Expand Down
12 changes: 5 additions & 7 deletions tests/integrations/huggingface_hub/test_huggingface_hub.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import itertools
from unittest import mock

import pytest
from huggingface_hub import (
Expand All @@ -9,8 +10,6 @@
from sentry_sdk import start_transaction
from sentry_sdk.integrations.huggingface_hub import HuggingfaceHubIntegration

from unittest import mock # python 3.3 and above


def mock_client_post(client, post_mock):
# huggingface-hub==0.28.0 deprecates the `post` method
Expand All @@ -33,7 +32,7 @@ def test_nonstreaming_chat_completion(
)
events = capture_events()

client = InferenceClient("some-model")
client = InferenceClient()
if details_arg:
post_mock = mock.Mock(
return_value=b"""[{
Expand Down Expand Up @@ -92,7 +91,7 @@ def test_streaming_chat_completion(
)
events = capture_events()

client = InferenceClient("some-model")
client = InferenceClient()

post_mock = mock.Mock(
return_value=[
Expand All @@ -116,7 +115,6 @@ def test_streaming_chat_completion(
)
)
assert len(response) == 2
print(response)
if details_arg:
assert response[0].token.text + response[1].token.text == "the model response"
else:
Expand All @@ -142,7 +140,7 @@ def test_bad_chat_completion(sentry_init, capture_events):
sentry_init(integrations=[HuggingfaceHubIntegration()], traces_sample_rate=1.0)
events = capture_events()

client = InferenceClient("some-model")
client = InferenceClient()
post_mock = mock.Mock(side_effect=OverloadedError("The server is overloaded"))
mock_client_post(client, post_mock)

Expand All @@ -160,7 +158,7 @@ def test_span_origin(sentry_init, capture_events):
)
events = capture_events()

client = InferenceClient("some-model")
client = InferenceClient()
post_mock = mock.Mock(
return_value=[
b"""data:{
Expand Down
14 changes: 14 additions & 0 deletions tox.ini
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't the hardcoded huggingface_hub items from tox.ini also be getting removed here and/or in the yml template?

Copy link
Member

Choose a reason for hiding this comment

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

seems like they have not been in tox.ini in the first place...

Copy link
Member

Choose a reason for hiding this comment

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

sus lol

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 I think they were missing for some time 🙃

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 went through the rest of the integrations not managed by toxgen to make sure this wasn't the case for other test suites -- we should be good

Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ envlist =
# These come from the populate_tox.py script. Eventually we should move all
# integration tests there.

# ~~~ AI ~~~
{py3.8,py3.10,py3.11}-huggingface_hub-v0.22.2
{py3.8,py3.10,py3.11}-huggingface_hub-v0.25.2
{py3.8,py3.12,py3.13}-huggingface_hub-v0.28.1
{py3.8,py3.12,py3.13}-huggingface_hub-v0.30.2


# ~~~ DBs ~~~
{py3.7,py3.11,py3.12}-clickhouse_driver-v0.2.9

Expand Down Expand Up @@ -519,6 +526,13 @@ deps =
# These come from the populate_tox.py script. Eventually we should move all
# integration tests there.

# ~~~ AI ~~~
huggingface_hub-v0.22.2: huggingface_hub==0.22.2
huggingface_hub-v0.25.2: huggingface_hub==0.25.2
huggingface_hub-v0.28.1: huggingface_hub==0.28.1
huggingface_hub-v0.30.2: huggingface_hub==0.30.2


# ~~~ DBs ~~~
clickhouse_driver-v0.2.9: clickhouse-driver==0.2.9

Expand Down
Loading