From 2c252a418a79051a9c4f7d01732971c5a2f2e372 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 30 May 2025 10:37:15 +1000 Subject: [PATCH 1/4] chore(ci): unmark test as fixture --- generative_ai/embeddings/test_embeddings_examples.py | 1 - 1 file changed, 1 deletion(-) diff --git a/generative_ai/embeddings/test_embeddings_examples.py b/generative_ai/embeddings/test_embeddings_examples.py index b4472d25a56..25eef26431f 100644 --- a/generative_ai/embeddings/test_embeddings_examples.py +++ b/generative_ai/embeddings/test_embeddings_examples.py @@ -35,7 +35,6 @@ @backoff.on_exception(backoff.expo, ResourceExhausted, max_time=10) -@pytest.fixture(scope="session") def test_embed_text_batch() -> None: os.environ["GCS_OUTPUT_URI"] = "gs://python-docs-samples-tests/" batch_prediction_job = batch_example.embed_text_batch() From 2924fb9942e50e18f07904a9de95fcdf6cd44f36 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 30 May 2025 11:11:58 +1000 Subject: [PATCH 2/4] lint --- generative_ai/embeddings/test_embeddings_examples.py | 1 - 1 file changed, 1 deletion(-) diff --git a/generative_ai/embeddings/test_embeddings_examples.py b/generative_ai/embeddings/test_embeddings_examples.py index 25eef26431f..a3dfaaf9d72 100644 --- a/generative_ai/embeddings/test_embeddings_examples.py +++ b/generative_ai/embeddings/test_embeddings_examples.py @@ -22,7 +22,6 @@ from google.cloud import aiplatform from google.cloud.aiplatform import initializer as aiplatform_init -import pytest import batch_example import code_retrieval_example From 77671b0eaf37cbff1b607cc62933e10a1030974c Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 30 May 2025 11:12:01 +1000 Subject: [PATCH 3/4] refactor test: pass the output_uri as a parameter, rather than environ --- generative_ai/embeddings/batch_example.py | 3 +-- generative_ai/embeddings/test_embeddings_examples.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/generative_ai/embeddings/batch_example.py b/generative_ai/embeddings/batch_example.py index 91be92de79b..ecb71cc1fcd 100644 --- a/generative_ai/embeddings/batch_example.py +++ b/generative_ai/embeddings/batch_example.py @@ -16,10 +16,9 @@ from google.cloud.aiplatform import BatchPredictionJob PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") -OUTPUT_URI = os.getenv("GCS_OUTPUT_URI") -def embed_text_batch() -> BatchPredictionJob: +def embed_text_batch(OUTPUT_URI) -> BatchPredictionJob: """Example of how to generate embeddings from text using batch processing. Read more: https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/batch-prediction-genai-embeddings diff --git a/generative_ai/embeddings/test_embeddings_examples.py b/generative_ai/embeddings/test_embeddings_examples.py index a3dfaaf9d72..b430b978e2c 100644 --- a/generative_ai/embeddings/test_embeddings_examples.py +++ b/generative_ai/embeddings/test_embeddings_examples.py @@ -35,8 +35,7 @@ @backoff.on_exception(backoff.expo, ResourceExhausted, max_time=10) def test_embed_text_batch() -> None: - os.environ["GCS_OUTPUT_URI"] = "gs://python-docs-samples-tests/" - batch_prediction_job = batch_example.embed_text_batch() + batch_prediction_job = batch_example.embed_text_batch("gs://python-docs-samples-tests/") assert batch_prediction_job From 74acdbb831848c138991c8b7c3d31904650df8d8 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 30 May 2025 12:09:53 +1000 Subject: [PATCH 4/4] lint --- generative_ai/embeddings/batch_example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generative_ai/embeddings/batch_example.py b/generative_ai/embeddings/batch_example.py index ecb71cc1fcd..bffb7419ae4 100644 --- a/generative_ai/embeddings/batch_example.py +++ b/generative_ai/embeddings/batch_example.py @@ -18,7 +18,7 @@ PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") -def embed_text_batch(OUTPUT_URI) -> BatchPredictionJob: +def embed_text_batch(OUTPUT_URI: str) -> BatchPredictionJob: """Example of how to generate embeddings from text using batch processing. Read more: https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/batch-prediction-genai-embeddings