GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: GenAI Client(evals) - Pass client credentials and http_options t… · hamgor/python-aiplatform@58c34ea

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • agentplatform/_genai
    • _evals_common.py
  • tests/unit/agentplatform/genai
    • test_evals.py
  • vertexai/_genai
    • _evals_common.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎agentplatform/_genai/_evals_common.py‎

Copy file name to clipboardExpand all lines: agentplatform/_genai/_evals_common.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ def _get_runtime_instance(
154154
client = agentplatform.Client(
155155
project=api_client.project,
156156
location=api_client.location,
157+
credentials=api_client._credentials,
158+
http_options=api_client._http_options,
157159
)
158160
_thread_local_data.runtime_instances[agent_name] = client.runtimes.get(
159161
name=agent_name
Collapse file

‎tests/unit/agentplatform/genai/test_evals.py‎

Copy file name to clipboardExpand all lines: tests/unit/agentplatform/genai/test_evals.py
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,41 @@ def test_get_api_client_with_none_location(
234234
mock_agentplatform_client.assert_not_called()
235235

236236

237+
class TestGetRuntimeInstance:
238+
_RUNTIME_NAME = "projects/test-project/locations/us-central1/reasoningEngines/123"
239+
240+
def setup_method(self):
241+
if hasattr(_evals_common._thread_local_data, "runtime_instances"):
242+
del _evals_common._thread_local_data.runtime_instances
243+
244+
def teardown_method(self):
245+
if hasattr(_evals_common._thread_local_data, "runtime_instances"):
246+
del _evals_common._thread_local_data.runtime_instances
247+
248+
@mock.patch.object(_evals_common.agentplatform, "Client")
249+
def test_get_runtime_instance_uses_client_credentials_and_http_options(
250+
self, mock_agentplatform_client, mock_api_client_fixture
251+
):
252+
mock_api_client_fixture._http_options = genai_types.HttpOptions(
253+
base_url="https://custom-endpoint.example.com/"
254+
)
255+
runtime = _evals_common._get_runtime_instance(
256+
self._RUNTIME_NAME, mock_api_client_fixture
257+
)
258+
mock_agentplatform_client.assert_called_once_with(
259+
project=mock_api_client_fixture.project,
260+
location=mock_api_client_fixture.location,
261+
credentials=mock_api_client_fixture._credentials,
262+
http_options=mock_api_client_fixture._http_options,
263+
)
264+
mock_agentplatform_client.return_value.runtimes.get.assert_called_once_with(
265+
name=self._RUNTIME_NAME
266+
)
267+
assert runtime is (
268+
mock_agentplatform_client.return_value.runtimes.get.return_value
269+
)
270+
271+
237272
class TestNormalizeInferenceModelName:
238273
_FQ_PREFIX = f"projects/{_TEST_PROJECT}/locations/{_TEST_LOCATION}/"
239274

Collapse file

‎vertexai/_genai/_evals_common.py‎

Copy file name to clipboardExpand all lines: vertexai/_genai/_evals_common.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def _get_agent_engine_instance(
124124
client = vertexai.Client(
125125
project=api_client.project,
126126
location=api_client.location,
127+
credentials=api_client._credentials,
128+
http_options=api_client._http_options,
127129
)
128130
_thread_local_data.agent_engine_instances[agent_name] = (
129131
client.agent_engines.get(name=agent_name)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.