From f84e695e0e1af7698defe5fec1e08cf510b70525 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Sun, 14 Dec 2025 11:49:52 -0500 Subject: [PATCH 1/9] chore: trivial change to trigger CI --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 20f1413155..0cf8c9d7e4 100644 --- a/README.rst +++ b/README.rst @@ -8,6 +8,8 @@ Vertex AI SDK for Python - `Client Library Documentation`_ - `Product Documentation`_ + + .. |GA| image:: https://img.shields.io/badge/support-ga-gold.svg :target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#general-availability .. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-aiplatform.svg From 5712656607c05289f9d42fe74d242cb51c8d3bef Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Sun, 14 Dec 2025 16:51:06 -0500 Subject: [PATCH 2/9] fix: Separate unit tests and fix asyncio in test_predict\n\n- Separated unit tests into unit and unit-minimal sessions to handle different dependency needs.\n- Added @pytest.mark.asyncio to TestModelServer.test_predict. --- noxfile.py | 18 ++++++++++-------- tests/unit/aiplatform/test_prediction.py | 5 ++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/noxfile.py b/noxfile.py index 2ea6d71713..6ec1565fa1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -97,6 +97,7 @@ # 'docfx' is excluded since it only needs to run in 'docs-presubmit' nox.options.sessions = [ "unit", + "unit_minimal", "unit_ray", "unit_langchain", "unit_ag2", @@ -219,6 +220,7 @@ def default(session): "--ignore=tests/unit/vertex_ag2", "--ignore=tests/unit/vertex_llama_index", "--ignore=tests/unit/architecture", + "--ignore=tests/unit/vertexai/test_generative_models.py", # Exclude minimal tests os.path.join("tests", "unit"), *session.posargs, ) @@ -235,11 +237,7 @@ def default(session): @nox.session(python=UNIT_TEST_PYTHON_VERSIONS) def unit(session): - """Run the unit test suite.""" - # First run the minimal GenAI tests - unit_genai_minimal_dependencies(session) - - # Then run the default full test suite + """Run the default unit test suite.""" default(session) @@ -254,14 +252,18 @@ def unit_genai_minimal_dependencies(session): session.run( "py.test", "--quiet", - f"--junitxml=unit_{session.python}_sponge_log.xml", - # These tests require the PIL module - # "--ignore=TestGenerativeModels::test_image_mime_types", + f"--junitxml=unit_minimal_{session.python}_sponge_log.xml", os.path.join("tests", "unit", "vertexai", "test_generative_models.py"), *session.posargs, ) +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +def unit_minimal(session): + """Run the minimal GenAI unit tests.""" + unit_genai_minimal_dependencies(session) + + @nox.session(python=["3.10", "3.11"]) @nox.parametrize("ray", ["2.9.3", "2.33.0", "2.42.0", "2.47.1"]) def unit_ray(session, ray): diff --git a/tests/unit/aiplatform/test_prediction.py b/tests/unit/aiplatform/test_prediction.py index a1b49f9862..62e2f1a436 100644 --- a/tests/unit/aiplatform/test_prediction.py +++ b/tests/unit/aiplatform/test_prediction.py @@ -3279,6 +3279,7 @@ def test_init_no_aip_predict_route( assert str(exception.value) == expected_message + def test_health(self, model_server_env_mock, importlib_import_module_mock_twice): model_server = CprModelServer() client = TestClient(model_server.app) @@ -3287,10 +3288,12 @@ def test_health(self, model_server_env_mock, importlib_import_module_mock_twice) assert response.status_code == 200 - def test_predict(self, model_server_env_mock, importlib_import_module_mock_twice): + @pytest.mark.asyncio + async def test_predict(self, model_server_env_mock, importlib_import_module_mock_twice): model_server = CprModelServer() client = TestClient(model_server.app) + with mock.patch.object(model_server.handler, "handle") as handle_mock: future = asyncio.Future() future.set_result(Response()) From f65254942d32bc11a4fddbdec78f8ddd3ed96a6e Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Mon, 15 Dec 2025 10:24:40 -0500 Subject: [PATCH 3/9] fix: Use == instead of .__eq__ in rag_corpus_eq\n\nReplaced .__eq__() with == for object comparisons in the rag_corpus_eq helper function to resolve TypeError in Python 3.14. --- tests/unit/vertex_rag/test_rag_data.py | 6 ++---- tests/unit/vertex_rag/test_rag_data_preview.py | 10 ++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/unit/vertex_rag/test_rag_data.py b/tests/unit/vertex_rag/test_rag_data.py index 94f6c35bf9..4dbacd4acc 100644 --- a/tests/unit/vertex_rag/test_rag_data.py +++ b/tests/unit/vertex_rag/test_rag_data.py @@ -419,10 +419,8 @@ def create_transformation_config( def rag_corpus_eq(returned_corpus, expected_corpus): assert returned_corpus.name == expected_corpus.name assert returned_corpus.display_name == expected_corpus.display_name - assert returned_corpus.backend_config.__eq__(expected_corpus.backend_config) - assert returned_corpus.vertex_ai_search_config.__eq__( - expected_corpus.vertex_ai_search_config - ) + assert returned_corpus.backend_config == expected_corpus.backend_config + assert returned_corpus.vertex_ai_search_config == expected_corpus.vertex_ai_search_config def rag_file_eq(returned_file, expected_file): diff --git a/tests/unit/vertex_rag/test_rag_data_preview.py b/tests/unit/vertex_rag/test_rag_data_preview.py index b887d40f52..19e21205bb 100644 --- a/tests/unit/vertex_rag/test_rag_data_preview.py +++ b/tests/unit/vertex_rag/test_rag_data_preview.py @@ -691,12 +691,10 @@ def create_transformation_config( def rag_corpus_eq(returned_corpus, expected_corpus): assert returned_corpus.name == expected_corpus.name assert returned_corpus.display_name == expected_corpus.display_name - assert returned_corpus.vector_db.__eq__(expected_corpus.vector_db) - assert returned_corpus.backend_config.__eq__(expected_corpus.backend_config) - assert returned_corpus.vertex_ai_search_config.__eq__( - expected_corpus.vertex_ai_search_config - ) - assert returned_corpus.corpus_type_config.__eq__(expected_corpus.corpus_type_config) + assert returned_corpus.vector_db == expected_corpus.vector_db + assert returned_corpus.backend_config == expected_corpus.backend_config + assert returned_corpus.vertex_ai_search_config == expected_corpus.vertex_ai_search_config + assert returned_corpus.corpus_type_config == expected_corpus.corpus_type_config def rag_file_eq(returned_file, expected_file): From c40e6a6737219f217fc4a328655b167bc4add16c Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Mon, 15 Dec 2025 11:11:39 -0500 Subject: [PATCH 4/9] fix: Add conditional pyarrow dependency for Ray\n\nPins pyarrow to >=6.0.1,<=14.0.2 for Python < 3.11 and >=15.0.0 for Python >= 3.11 to resolve ImportError in Ray tests. --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index bd3a7fe965..59bcc6bd55 100644 --- a/setup.py +++ b/setup.py @@ -317,6 +317,8 @@ "google-cloud-resource-manager >= 1.3.3, < 3.0.0", "shapely < 3.0.0", "google-genai >= 1.37.0, <2.0.0", + "pyarrow >= 6.0.1, <= 14.0.2; python_version < '3.11'", + "pyarrow >= 15.0.0; python_version >= '3.11'", ) + genai_requires, extras_require={ From 7146aca5c727207cd72f95d22072e7dc21fdd219 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Mon, 15 Dec 2025 11:18:38 -0500 Subject: [PATCH 5/9] fix: Make rag_corpus_eq more robust to oneof changes\n\nUpdated the rag_corpus_eq helper function to intelligently handle the oneof relationship between backend_config and vertex_ai_search_config, and the default backend_config instantiation. --- tests/unit/vertex_rag/test_rag_data.py | 14 ++++++++++++-- tests/unit/vertex_rag/test_rag_data_preview.py | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/unit/vertex_rag/test_rag_data.py b/tests/unit/vertex_rag/test_rag_data.py index 4dbacd4acc..c91dc57505 100644 --- a/tests/unit/vertex_rag/test_rag_data.py +++ b/tests/unit/vertex_rag/test_rag_data.py @@ -416,11 +416,21 @@ def create_transformation_config( ) +from vertexai.rag.utils.resources import RagVectorDbConfig + def rag_corpus_eq(returned_corpus, expected_corpus): assert returned_corpus.name == expected_corpus.name assert returned_corpus.display_name == expected_corpus.display_name - assert returned_corpus.backend_config == expected_corpus.backend_config - assert returned_corpus.vertex_ai_search_config == expected_corpus.vertex_ai_search_config + + if expected_corpus.vertex_ai_search_config: + assert returned_corpus.vertex_ai_search_config == expected_corpus.vertex_ai_search_config + assert returned_corpus.backend_config == RagVectorDbConfig(vector_db=None, rag_embedding_model_config=None) + elif expected_corpus.backend_config: + assert returned_corpus.backend_config == expected_corpus.backend_config + assert returned_corpus.vertex_ai_search_config is None + else: + assert returned_corpus.backend_config == RagVectorDbConfig(vector_db=None, rag_embedding_model_config=None) + assert returned_corpus.vertex_ai_search_config is None def rag_file_eq(returned_file, expected_file): diff --git a/tests/unit/vertex_rag/test_rag_data_preview.py b/tests/unit/vertex_rag/test_rag_data_preview.py index 19e21205bb..f9cb831910 100644 --- a/tests/unit/vertex_rag/test_rag_data_preview.py +++ b/tests/unit/vertex_rag/test_rag_data_preview.py @@ -688,14 +688,24 @@ def create_transformation_config( ) +from vertexai.rag.utils.resources import RagVectorDbConfig + def rag_corpus_eq(returned_corpus, expected_corpus): assert returned_corpus.name == expected_corpus.name assert returned_corpus.display_name == expected_corpus.display_name assert returned_corpus.vector_db == expected_corpus.vector_db - assert returned_corpus.backend_config == expected_corpus.backend_config - assert returned_corpus.vertex_ai_search_config == expected_corpus.vertex_ai_search_config assert returned_corpus.corpus_type_config == expected_corpus.corpus_type_config + if expected_corpus.vertex_ai_search_config: + assert returned_corpus.vertex_ai_search_config == expected_corpus.vertex_ai_search_config + assert returned_corpus.backend_config == RagVectorDbConfig(vector_db=None, rag_embedding_model_config=None) + elif expected_corpus.backend_config: + assert returned_corpus.backend_config == expected_corpus.backend_config + assert returned_corpus.vertex_ai_search_config is None + else: + assert returned_corpus.backend_config == RagVectorDbConfig(vector_db=None, rag_embedding_model_config=None) + assert returned_corpus.vertex_ai_search_config is None + def rag_file_eq(returned_file, expected_file): assert returned_file.name == expected_file.name From df1340a8293ecd427cb3906484f3f5742e64ab3d Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Mon, 15 Dec 2025 11:43:45 -0500 Subject: [PATCH 6/9] Revert "fix: Add conditional pyarrow dependency for Ray\n\nPins pyarrow to >=6.0.1,<=14.0.2 for Python < 3.11 and >=15.0.0 for Python >= 3.11 to resolve ImportError in Ray tests." This reverts commit c40e6a6737219f217fc4a328655b167bc4add16c. --- setup.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/setup.py b/setup.py index 59bcc6bd55..bd3a7fe965 100644 --- a/setup.py +++ b/setup.py @@ -317,8 +317,6 @@ "google-cloud-resource-manager >= 1.3.3, < 3.0.0", "shapely < 3.0.0", "google-genai >= 1.37.0, <2.0.0", - "pyarrow >= 6.0.1, <= 14.0.2; python_version < '3.11'", - "pyarrow >= 15.0.0; python_version >= '3.11'", ) + genai_requires, extras_require={ From be5b093a3ffea2c2b2abc1aa1cc2181edafdee0c Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Mon, 15 Dec 2025 11:47:38 -0500 Subject: [PATCH 7/9] fix: Resolve Ray and Langchain dependency issues\n\n- Reverted pyarrow pins in setup.py\n- Pinned numpy<2.0.0 in Ray constraints files\n- Added try/except for Ray ClientContext instantiation\n- Pinned pyarrow>=19.0.1 in langchain constraints --- testing/constraints-langchain.txt | 3 ++- testing/constraints-ray-2.33.0.txt | 1 + testing/constraints-ray-2.42.0.txt | 1 + testing/constraints-ray-2.9.3.txt | 1 + .../unit/vertex_ray/test_vertex_ray_client.py | 27 +++++++++++++------ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/testing/constraints-langchain.txt b/testing/constraints-langchain.txt index 9768def9f3..40ad02e2eb 100644 --- a/testing/constraints-langchain.txt +++ b/testing/constraints-langchain.txt @@ -1,4 +1,5 @@ langchain langchain-core langchain-google-vertexai -langgraph-checkpoint==2.0.1 # Pinned to unbreak unit tests. \ No newline at end of file +langgraph-checkpoint==2.0.1 # Pinned to unbreak unit tests. +pyarrow>=19.0.1 \ No newline at end of file diff --git a/testing/constraints-ray-2.33.0.txt b/testing/constraints-ray-2.33.0.txt index 10bc7c96f9..ba1fdb3fbb 100644 --- a/testing/constraints-ray-2.33.0.txt +++ b/testing/constraints-ray-2.33.0.txt @@ -1,4 +1,5 @@ ray==2.33.0 +numpy<2.0.0 # Ray 2.33.0 not compatible with NumPy 2.x # Below constraints are inherited from constraints-3.10.txt google-api-core proto-plus==1.22.3 diff --git a/testing/constraints-ray-2.42.0.txt b/testing/constraints-ray-2.42.0.txt index 5844dca74f..b03391b2b2 100644 --- a/testing/constraints-ray-2.42.0.txt +++ b/testing/constraints-ray-2.42.0.txt @@ -1,4 +1,5 @@ ray==2.42.0 +numpy<2.0.0 # Ray 2.42.0 not compatible with NumPy 2.x on Py 3.10 # Below constraints are inherited from constraints-3.10.txt google-api-core proto-plus==1.22.3 diff --git a/testing/constraints-ray-2.9.3.txt b/testing/constraints-ray-2.9.3.txt index c4c1ea816c..03023a2cba 100644 --- a/testing/constraints-ray-2.9.3.txt +++ b/testing/constraints-ray-2.9.3.txt @@ -1,4 +1,5 @@ ray==2.9.3 +numpy<2.0.0 # Ray 2.9.3 not compatible with NumPy 2.x # Below constraints are inherited from constraints-3.10.txt setuptools<70.0.0 google-api-core diff --git a/tests/unit/vertex_ray/test_vertex_ray_client.py b/tests/unit/vertex_ray/test_vertex_ray_client.py index a896b101b4..9bd7d868d3 100644 --- a/tests/unit/vertex_ray/test_vertex_ray_client.py +++ b/tests/unit/vertex_ray/test_vertex_ray_client.py @@ -24,14 +24,25 @@ # -*- coding: utf-8 -*- -_TEST_CLIENT_CONTEXT = ray.client_builder.ClientContext( - dashboard_url=tc.ClusterConstants.TEST_VERTEX_RAY_DASHBOARD_ADDRESS, - python_version="MOCK_PYTHON_VERSION", - ray_version="MOCK_RAY_VERSION", - ray_commit="MOCK_RAY_COMMIT", - _num_clients=1, - _context_to_restore=None, -) +try: + _TEST_CLIENT_CONTEXT = ray.client_builder.ClientContext( + dashboard_url=tc.ClusterConstants.TEST_VERTEX_RAY_DASHBOARD_ADDRESS, + python_version="MOCK_PYTHON_VERSION", + ray_version="MOCK_RAY_VERSION", + ray_commit="MOCK_RAY_COMMIT", + protocol_version=0, + _num_clients=1, + _context_to_restore=None, + ) +except TypeError: + _TEST_CLIENT_CONTEXT = ray.client_builder.ClientContext( + dashboard_url=tc.ClusterConstants.TEST_VERTEX_RAY_DASHBOARD_ADDRESS, + python_version="MOCK_PYTHON_VERSION", + ray_version="MOCK_RAY_VERSION", + ray_commit="MOCK_RAY_COMMIT", + _num_clients=1, + _context_to_restore=None, + ) _TEST_VERTEX_RAY_CLIENT_CONTEXT = vertex_ray.client_builder._VertexRayClientContext( persistent_resource_id="MOCK_PERSISTENT_RESOURCE_ID", From d80e0251ee6a5f9e4e36b662a8d3a26237bcc894 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Mon, 15 Dec 2025 12:37:00 -0500 Subject: [PATCH 8/9] fix: Pin pyarrow for Ray 2.9.3 on Python 3.10 --- testing/constraints-ray-2.9.3.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/constraints-ray-2.9.3.txt b/testing/constraints-ray-2.9.3.txt index 03023a2cba..c965ab1221 100644 --- a/testing/constraints-ray-2.9.3.txt +++ b/testing/constraints-ray-2.9.3.txt @@ -1,5 +1,6 @@ ray==2.9.3 numpy<2.0.0 # Ray 2.9.3 not compatible with NumPy 2.x +pyarrow>=6.0.1,<=14.0.2 # Below constraints are inherited from constraints-3.10.txt setuptools<70.0.0 google-api-core From 89c5d9db713c210927504512a81c96288bf86ec8 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Mon, 15 Dec 2025 12:57:57 -0500 Subject: [PATCH 9/9] chore: Add debug printing to RAG tests --- tests/unit/vertex_rag/test_rag_data.py | 4 ++++ tests/unit/vertex_rag/test_rag_data_preview.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tests/unit/vertex_rag/test_rag_data.py b/tests/unit/vertex_rag/test_rag_data.py index c91dc57505..29c61b9610 100644 --- a/tests/unit/vertex_rag/test_rag_data.py +++ b/tests/unit/vertex_rag/test_rag_data.py @@ -419,6 +419,10 @@ def create_transformation_config( from vertexai.rag.utils.resources import RagVectorDbConfig def rag_corpus_eq(returned_corpus, expected_corpus): + if returned_corpus != expected_corpus: + print(f"Returned Corpus: {returned_corpus}") + print(f"Expected Corpus: {expected_corpus}") + assert returned_corpus.name == expected_corpus.name assert returned_corpus.display_name == expected_corpus.display_name diff --git a/tests/unit/vertex_rag/test_rag_data_preview.py b/tests/unit/vertex_rag/test_rag_data_preview.py index f9cb831910..b587066822 100644 --- a/tests/unit/vertex_rag/test_rag_data_preview.py +++ b/tests/unit/vertex_rag/test_rag_data_preview.py @@ -691,6 +691,10 @@ def create_transformation_config( from vertexai.rag.utils.resources import RagVectorDbConfig def rag_corpus_eq(returned_corpus, expected_corpus): + if returned_corpus != expected_corpus: + print(f"Returned Corpus: {returned_corpus}") + print(f"Expected Corpus: {expected_corpus}") + assert returned_corpus.name == expected_corpus.name assert returned_corpus.display_name == expected_corpus.display_name assert returned_corpus.vector_db == expected_corpus.vector_db