From 0f4a08718630d9cd3e023dd40a7a7462e339ffbe Mon Sep 17 00:00:00 2001 From: Bagatur <22008038+baskaryan@users.noreply.github.com> Date: Mon, 9 Sep 2024 10:35:41 -0700 Subject: [PATCH] community[patch]: fix main unit tests (#26189) --- .../retrievers/google_vertex_ai_search.py | 13 +++++-------- libs/community/pyproject.toml | 3 +++ .../tests/unit_tests/load/test_serializable.py | 5 +++++ .../community/tests/unit_tests/test_dependencies.py | 3 +++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/libs/community/langchain_community/retrievers/google_vertex_ai_search.py b/libs/community/langchain_community/retrievers/google_vertex_ai_search.py index 41625823567..109f0385f0c 100644 --- a/libs/community/langchain_community/retrievers/google_vertex_ai_search.py +++ b/libs/community/langchain_community/retrievers/google_vertex_ai_search.py @@ -15,12 +15,7 @@ from langchain_community.utilities.vertexai import get_client_info if TYPE_CHECKING: from google.api_core.client_options import ClientOptions - from google.cloud.discoveryengine_v1beta import ( - ConversationalSearchServiceClient, - SearchRequest, - SearchResult, - SearchServiceClient, - ) + from google.cloud.discoveryengine_v1beta import SearchRequest, SearchResult class _BaseGoogleVertexAISearchRetriever(BaseModel): @@ -243,7 +238,8 @@ class GoogleVertexAISearchRetriever(BaseRetriever, _BaseGoogleVertexAISearchRetr Search will be based on the corrected query if found. """ - _client: SearchServiceClient + # type is SearchServiceClient but can't be set due to optional imports + _client: Any _serving_config: str model_config = ConfigDict( @@ -408,7 +404,8 @@ class GoogleVertexAIMultiTurnSearchRetriever( conversation_id: str = "-" """Vertex AI Search Conversation ID.""" - _client: ConversationalSearchServiceClient + # type is ConversationalSearchServiceClient but can't be set due to optional imports + _client: Any _serving_config: str model_config = ConfigDict( diff --git a/libs/community/pyproject.toml b/libs/community/pyproject.toml index d622bf0c6f3..dbc4617541f 100644 --- a/libs/community/pyproject.toml +++ b/libs/community/pyproject.toml @@ -65,6 +65,9 @@ markers = [ "compile: mark placeholder test used to compile integration tests without running them", ] asyncio_mode = "auto" +filterwarnings = [ + "ignore::langchain_core._api.deprecation.LangChainDeprecationWarning:test", +] [tool.poetry.group.test] optional = true diff --git a/libs/community/tests/unit_tests/load/test_serializable.py b/libs/community/tests/unit_tests/load/test_serializable.py index f86d2f70739..35ea4b169d7 100644 --- a/libs/community/tests/unit_tests/load/test_serializable.py +++ b/libs/community/tests/unit_tests/load/test_serializable.py @@ -120,6 +120,11 @@ def test_serializable_mapping() -> None: "bedrock", "ChatBedrock", ), + ("langchain_google_genai", "chat_models", "ChatGoogleGenerativeAI"): ( + "langchain_google_genai", + "chat_models", + "ChatGoogleGenerativeAI", + ), } serializable_modules = import_all_modules("langchain") diff --git a/libs/community/tests/unit_tests/test_dependencies.py b/libs/community/tests/unit_tests/test_dependencies.py index 47239c945d2..8fe12f140f1 100644 --- a/libs/community/tests/unit_tests/test_dependencies.py +++ b/libs/community/tests/unit_tests/test_dependencies.py @@ -93,6 +93,9 @@ def test_test_group_dependencies(poetry_conf: Mapping[str, Any]) -> None: "responses", "syrupy", "requests-mock", + # TODO: Hack to get around cffi 1.17.1 not working with py3.9, remove when + # fix is released. + "cffi", ] )