Skip to content

Commit 186be4d

Browse files
committed
Pulled in vcrpy v8 for unused cassettes and httpcore stubs
1 parent 931d39f commit 186be4d

File tree

5 files changed

+29
-19
lines changed

5 files changed

+29
-19
lines changed

packages/paper-qa-nemotron/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ dev = [
5050
"pytest-recording",
5151
"pytest-rerunfailures",
5252
"pytest>=9", # Pin for pytest-subtests upstreaming
53-
"vcrpy>=6", # Pin for https://github.com/kevin1024/vcrpy/issues/884
53+
"vcrpy>=8", # Pin for dropping unused cassettes support
5454
]
5555
sagemaker = ["aiobotocore"]
5656
typing = [

packages/paper-qa-nemotron/tests/conftest.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import httpx_aiohttp
66
import litellm.llms.custom_httpx.aiohttp_transport
77
import pytest
8-
import vcr.stubs.httpx_stubs
8+
import vcr.stubs.httpcore_stubs
99
from lmi.utils import (
1010
ANTHROPIC_API_KEY_HEADER,
1111
CROSSREF_KEY_HEADER,
@@ -29,6 +29,7 @@ def fixture_vcr_config() -> dict[str, Any]:
2929
],
3030
"record_mode": "once",
3131
"cassette_library_dir": str(CASSETTES_DIR),
32+
"drop_unused_requests": True,
3233
}
3334

3435

@@ -50,9 +51,14 @@ async def __aiter__(self) -> AsyncIterator[bytes]:
5051
yield chunk
5152

5253

53-
async def _async_vcr_send(cassette, real_send, *args, **kwargs): # noqa: ARG001
54-
"""VCR send that only sends, not possibly recording or playing back responses."""
55-
return await real_send(*args, **kwargs)
54+
async def _vcr_handle_async_request(
55+
cassette, # noqa: ARG001
56+
real_handle_async_request,
57+
self,
58+
real_request,
59+
):
60+
"""VCR handler that only sends, not possibly recording or playing back responses."""
61+
return await real_handle_async_request(self, real_request)
5662

5763

5864
# Permanently patch the original response stream,
@@ -64,4 +70,4 @@ async def _async_vcr_send(cassette, real_send, *args, **kwargs): # noqa: ARG001
6470

6571
# Permanently patch vcrpy's async VCR recording functionality,
6672
# to work around https://github.com/kevin1024/vcrpy/issues/944
67-
vcr.stubs.httpx_stubs._async_vcr_send = _async_vcr_send
73+
vcr.stubs.httpcore_stubs._vcr_handle_async_request = _vcr_handle_async_request

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ dev = [
8181
"python-dotenv",
8282
"refurb>=2", # Pin to keep recent
8383
"typeguard",
84-
"vcrpy>=6", # Pin for https://github.com/kevin1024/vcrpy/issues/884
84+
"vcrpy>=8", # Pin for dropping unused cassettes support
8585
]
8686
docling = ["paper-qa-docling"]
8787
image = ["fhlmi[image]"]

tests/conftest.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import httpx_aiohttp
1414
import litellm.llms.custom_httpx.aiohttp_transport
1515
import pytest
16-
import vcr.stubs.httpx_stubs
16+
import vcr.stubs.httpcore_stubs
1717
from dotenv import load_dotenv
1818
from lmi.utils import (
1919
ANTHROPIC_API_KEY_HEADER,
@@ -117,6 +117,7 @@ def fixture_vcr_config() -> dict[str, Any]:
117117
"record_mode": "once" if not IN_GITHUB_ACTIONS else "none",
118118
"allow_playback_repeats": True,
119119
"cassette_library_dir": str(CASSETTES_DIR),
120+
"drop_unused_requests": True,
120121
}
121122

122123

@@ -213,9 +214,14 @@ async def __aiter__(self) -> AsyncIterator[bytes]:
213214
yield chunk
214215

215216

216-
async def _async_vcr_send(cassette, real_send, *args, **kwargs): # noqa: ARG001
217-
"""VCR send that only sends, not possibly recording or playing back responses."""
218-
return await real_send(*args, **kwargs)
217+
async def _vcr_handle_async_request(
218+
cassette, # noqa: ARG001
219+
real_handle_async_request,
220+
self,
221+
real_request,
222+
):
223+
"""VCR handler that only sends, not possibly recording or playing back responses."""
224+
return await real_handle_async_request(self, real_request)
219225

220226

221227
# Permanently patch the original response stream,
@@ -227,4 +233,4 @@ async def _async_vcr_send(cassette, real_send, *args, **kwargs): # noqa: ARG001
227233

228234
# Permanently patch vcrpy's async VCR recording functionality,
229235
# to work around https://github.com/kevin1024/vcrpy/issues/944
230-
vcr.stubs.httpx_stubs._async_vcr_send = _async_vcr_send
236+
vcr.stubs.httpcore_stubs._vcr_handle_async_request = _vcr_handle_async_request

uv.lock

Lines changed: 5 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)