Skip to content

[chore] Address TODO to migrate to VCRpy and remove bespoke RequestMocker code in Google GenAI SDK instrumentation #3344

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
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9d5b390
Remove bespoke request mocker. Replace with direct mocking of the und…
michaelsafyan Mar 5, 2025
82ea24a
Refactor fake credentials to enable reuse.
michaelsafyan Mar 5, 2025
3f621c2
Add module to test end to end with a real client.
michaelsafyan Mar 5, 2025
4424465
Add redaction and minimal OTel mocking/testing in the e2e test.
michaelsafyan Mar 6, 2025
1425789
Fix wording of the documentation.
michaelsafyan Mar 6, 2025
7b5605b
Remove vcr migration from TODOs.
michaelsafyan Mar 6, 2025
ed424fd
Merge branch 'main' into google_genai_test_improvements
michaelsafyan Mar 6, 2025
38be0b1
Improve redaction and test naming.
michaelsafyan Mar 6, 2025
6fdb82e
Merge branch 'main' into google_genai_test_improvements
michaelsafyan Mar 7, 2025
6a366d0
Minor tweaks in the code generation. Add casette files.
michaelsafyan Mar 7, 2025
1692b9e
Reformat with ruff.
michaelsafyan Mar 7, 2025
cdbb960
Merge branch 'main' into google_genai_test_improvements
michaelsafyan Mar 10, 2025
97d64b0
Merge branch 'main' into google_genai_test_improvements
michaelsafyan Mar 12, 2025
1e1def0
Merge branch 'main' into google_genai_test_improvements
michaelsafyan Mar 13, 2025
e7eb450
Fix lint and gzip issue.
michaelsafyan Mar 14, 2025
0ddc644
Reformat with ruff.
michaelsafyan Mar 14, 2025
60e09fa
Merge branch 'main' into google_genai_test_improvements
michaelsafyan Mar 14, 2025
6e35583
Prevent fix for Python 3.9 from breaking tests in other versions.
michaelsafyan Mar 14, 2025
2793544
Record update in changelog.
michaelsafyan Mar 14, 2025
c7ed0bb
Don't double iterate when redacting by changing the value.
michaelsafyan Mar 19, 2025
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
Next Next commit
Remove bespoke request mocker. Replace with direct mocking of the und…
…erlying API.
  • Loading branch information
michaelsafyan committed Mar 5, 2025
commit 9d5b390ca06ab5836eb3804f04ab75642abc1c63
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from .instrumentation_context import InstrumentationContext
from .otel_mocker import OTelMocker
from .requests_mocker import RequestsMocker


class _FakeCredentials(google.auth.credentials.AnonymousCredentials):
Expand All @@ -31,8 +30,6 @@ class TestCase(unittest.TestCase):
def setUp(self):
self._otel = OTelMocker()
self._otel.install()
self._requests = RequestsMocker()
self._requests.install()
self._instrumentation_context = None
self._api_key = "test-api-key"
self._project = "test-project"
Expand All @@ -51,17 +48,22 @@ def client(self):
self._client = self._create_client()
return self._client

@property
def requests(self):
return self._requests

@property
def otel(self):
return self._otel

def set_use_vertex(self, use_vertex):
self._uses_vertex = use_vertex

def reset_client(self):
self._client = None

def reset_instrumentation(self):
if self._instrumentation_context is None:
return
self._instrumentation_context.uninstall()
self._instrumentation_context = None

def _create_client(self):
self._lazy_init()
if self._uses_vertex:
Expand All @@ -77,5 +79,4 @@ def _create_client(self):
def tearDown(self):
if self._instrumentation_context is not None:
self._instrumentation_context.uninstall()
self._requests.uninstall()
self._otel.uninstall()

This file was deleted.

Loading