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

fix(ci): Various errors on master #4009

Merged
merged 6 commits into from
Jan 31, 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: 2 additions & 0 deletions sentry_sdk/_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@

class EmptyError(Exception):
"Exception raised by Queue.get(block=0)/get_nowait()."

pass


class FullError(Exception):
"Exception raised by Queue.put(block=0)/put_nowait()."

pass


Expand Down
11 changes: 10 additions & 1 deletion tests/integrations/aiohttp/test_aiohttp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import json
import sys
from contextlib import suppress
from unittest import mock

Expand Down Expand Up @@ -473,9 +474,17 @@ async def hello(request):
assert error_event["contexts"]["trace"]["trace_id"] == trace_id


if sys.version_info < (3, 12):
# `loop` was deprecated in `pytest-aiohttp`
# in favor of `event_loop` from `pytest-asyncio`
@pytest.fixture
def event_loop(loop):
yield loop


@pytest.mark.asyncio
async def test_crumb_capture(
sentry_init, aiohttp_raw_server, aiohttp_client, loop, capture_events
sentry_init, aiohttp_raw_server, aiohttp_client, event_loop, capture_events
):
def before_breadcrumb(crumb, hint):
crumb["data"]["extra"] = "foo"
Expand Down
26 changes: 21 additions & 5 deletions tests/integrations/huggingface_hub/test_huggingface_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
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
# so patch `_inner_post` instead
client.post = post_mock
client._inner_post = post_mock


@pytest.mark.parametrize(
"send_default_pii, include_prompts, details_arg",
itertools.product([True, False], repeat=3),
Expand All @@ -28,7 +35,7 @@ def test_nonstreaming_chat_completion(

client = InferenceClient("some-model")
if details_arg:
client.post = mock.Mock(
post_mock = mock.Mock(
return_value=b"""[{
"generated_text": "the model response",
"details": {
Expand All @@ -40,9 +47,11 @@ def test_nonstreaming_chat_completion(
}]"""
)
else:
client.post = mock.Mock(
post_mock = mock.Mock(
return_value=b'[{"generated_text": "the model response"}]'
)
mock_client_post(client, post_mock)

with start_transaction(name="huggingface_hub tx"):
response = client.text_generation(
prompt="hello",
Expand Down Expand Up @@ -84,7 +93,8 @@ def test_streaming_chat_completion(
events = capture_events()

client = InferenceClient("some-model")
client.post = mock.Mock(

post_mock = mock.Mock(
return_value=[
b"""data:{
"token":{"id":1, "special": false, "text": "the model "}
Expand All @@ -95,6 +105,8 @@ def test_streaming_chat_completion(
}""",
]
)
mock_client_post(client, post_mock)

with start_transaction(name="huggingface_hub tx"):
response = list(
client.text_generation(
Expand Down Expand Up @@ -131,7 +143,9 @@ def test_bad_chat_completion(sentry_init, capture_events):
events = capture_events()

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

with pytest.raises(OverloadedError):
client.text_generation(prompt="hello")

Expand All @@ -147,13 +161,15 @@ def test_span_origin(sentry_init, capture_events):
events = capture_events()

client = InferenceClient("some-model")
client.post = mock.Mock(
post_mock = mock.Mock(
return_value=[
b"""data:{
"token":{"id":1, "special": false, "text": "the model "}
}""",
]
)
mock_client_post(client, post_mock)

with start_transaction(name="huggingface_hub tx"):
list(
client.text_generation(
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/pymongo/test_pymongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@pytest.fixture(scope="session")
def mongo_server():
server = MockupDB(verbose=True)
server.autoresponds("ismaster", maxWireVersion=6)
server.autoresponds("ismaster", maxWireVersion=7)
server.run()
server.autoresponds(
{"find": "test_collection"}, cursor={"id": 123, "firstBatch": []}
Expand Down
Loading