Skip to content

Commit 3e33e76

Browse files
matthew29tangcopybara-github
authored andcommitted
chore: Fix oauth scope error for system tests (test_model_evaluation and test_language_models)
PiperOrigin-RevId: 594293058
1 parent 1f45584 commit 3e33e76

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

tests/system/aiplatform/test_language_models.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import pytest
2121

22-
22+
from google import auth
2323
from google.cloud import aiplatform
2424
from google.cloud.aiplatform.compat.types import (
2525
job_state as gca_job_state,
@@ -309,7 +309,14 @@ async def test_text_embedding_async(self):
309309

310310
def test_tuning(self, shared_state):
311311
"""Test tuning, listing and loading models."""
312-
aiplatform.init(project=e2e_base._PROJECT, location=e2e_base._LOCATION)
312+
credentials, _ = auth.default(
313+
scopes=["https://www.googleapis.com/auth/cloud-platform"]
314+
)
315+
aiplatform.init(
316+
project=e2e_base._PROJECT,
317+
location=e2e_base._LOCATION,
318+
credentials=credentials,
319+
)
313320

314321
model = language_models.TextGenerationModel.from_pretrained("text-bison@001")
315322

tests/system/aiplatform/test_model_evaluation.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"tear_down_resources",
6262
)
6363
class TestModelEvaluationJob(e2e_base.TestEndToEnd):
64-
6564
_temp_prefix = "temp_vertex_sdk_model_evaluation_test"
6665

6766
def setup_method(self):
@@ -84,12 +83,13 @@ def staging_bucket(self, storage_client):
8483
yield bucket
8584

8685
def test_model_evaluate_custom_tabular_model(self, staging_bucket, shared_state):
86+
credentials, _ = auth.default(
87+
scopes=["https://www.googleapis.com/auth/cloud-platform"]
88+
)
8789
aiplatform.init(
8890
project=_TEST_PROJECT,
8991
location=_TEST_LOCATION,
90-
credentials=auth.default(
91-
scopes=["https://www.googleapis.com/auth/cloud-platform"]
92-
),
92+
credentials=credentials,
9393
)
9494

9595
custom_model = aiplatform.Model(

0 commit comments

Comments
 (0)