Skip to content

Commit 0851458

Browse files
authored
toxgen: Add huggingface_hub (#4299)
Also fixes ``` Repository Not Found for url: https://huggingface.co/api/models/some-model. Please make sure you specified the correct `repo_id` and `repo_type`. If you are trying to access a private or gated repo, make sure you are authenticated. For more details, see https://huggingface.co/docs/huggingface_hub/authentication Invalid username or password. FAILED tests/integrations/huggingface_hub/test_huggingface_hub.py::test_span_origin - huggingface_hub.errors.RepositoryNotFoundError: 401 Client Error. (Request ID: Root=1-67fe4547-10b0ce8f541a41c37ead3b2a;afe45d5d-3af1-45cd-a39a-c8ef4a5211c3) ``` which started popping up on huggingface_hub 0.30.
1 parent fbf43bd commit 0851458

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

.github/workflows/test-integrations-ai.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
strategy:
105105
fail-fast: false
106106
matrix:
107-
python-version: ["3.8","3.9","3.11","3.12"]
107+
python-version: ["3.8","3.9","3.10","3.11","3.12","3.13"]
108108
# python3.6 reached EOL and is no longer being supported on
109109
# new versions of hosted runners on Github Actions
110110
# ubuntu-20.04 is the last version that supported python3.6

scripts/populate_tox/populate_tox.py

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
"fastapi",
7979
"gcp",
8080
"httpx",
81-
"huggingface_hub",
8281
"langchain",
8382
"langchain_notiktoken",
8483
"openai",

tests/integrations/huggingface_hub/test_huggingface_hub.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import itertools
2+
from unittest import mock
23

34
import pytest
45
from huggingface_hub import (
@@ -9,8 +10,6 @@
910
from sentry_sdk import start_transaction
1011
from sentry_sdk.integrations.huggingface_hub import HuggingfaceHubIntegration
1112

12-
from unittest import mock # python 3.3 and above
13-
1413

1514
def mock_client_post(client, post_mock):
1615
# huggingface-hub==0.28.0 deprecates the `post` method
@@ -33,7 +32,7 @@ def test_nonstreaming_chat_completion(
3332
)
3433
events = capture_events()
3534

36-
client = InferenceClient("some-model")
35+
client = InferenceClient()
3736
if details_arg:
3837
post_mock = mock.Mock(
3938
return_value=b"""[{
@@ -92,7 +91,7 @@ def test_streaming_chat_completion(
9291
)
9392
events = capture_events()
9493

95-
client = InferenceClient("some-model")
94+
client = InferenceClient()
9695

9796
post_mock = mock.Mock(
9897
return_value=[
@@ -116,7 +115,6 @@ def test_streaming_chat_completion(
116115
)
117116
)
118117
assert len(response) == 2
119-
print(response)
120118
if details_arg:
121119
assert response[0].token.text + response[1].token.text == "the model response"
122120
else:
@@ -142,7 +140,7 @@ def test_bad_chat_completion(sentry_init, capture_events):
142140
sentry_init(integrations=[HuggingfaceHubIntegration()], traces_sample_rate=1.0)
143141
events = capture_events()
144142

145-
client = InferenceClient("some-model")
143+
client = InferenceClient()
146144
post_mock = mock.Mock(side_effect=OverloadedError("The server is overloaded"))
147145
mock_client_post(client, post_mock)
148146

@@ -160,7 +158,7 @@ def test_span_origin(sentry_init, capture_events):
160158
)
161159
events = capture_events()
162160

163-
client = InferenceClient("some-model")
161+
client = InferenceClient()
164162
post_mock = mock.Mock(
165163
return_value=[
166164
b"""data:{

tox.ini

+14
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ envlist =
151151
# These come from the populate_tox.py script. Eventually we should move all
152152
# integration tests there.
153153

154+
# ~~~ AI ~~~
155+
{py3.8,py3.10,py3.11}-huggingface_hub-v0.22.2
156+
{py3.8,py3.10,py3.11}-huggingface_hub-v0.25.2
157+
{py3.8,py3.12,py3.13}-huggingface_hub-v0.28.1
158+
{py3.8,py3.12,py3.13}-huggingface_hub-v0.30.2
159+
160+
154161
# ~~~ DBs ~~~
155162
{py3.7,py3.11,py3.12}-clickhouse_driver-v0.2.9
156163

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

529+
# ~~~ AI ~~~
530+
huggingface_hub-v0.22.2: huggingface_hub==0.22.2
531+
huggingface_hub-v0.25.2: huggingface_hub==0.25.2
532+
huggingface_hub-v0.28.1: huggingface_hub==0.28.1
533+
huggingface_hub-v0.30.2: huggingface_hub==0.30.2
534+
535+
522536
# ~~~ DBs ~~~
523537
clickhouse_driver-v0.2.9: clickhouse-driver==0.2.9
524538

0 commit comments

Comments
 (0)