diff --git a/integration/test_client.py b/integration/test_client.py index 2891e3d2b..7742e197a 100644 --- a/integration/test_client.py +++ b/integration/test_client.py @@ -1,4 +1,6 @@ +import os from typing import Callable, Generator, Optional, Tuple, Union +from unittest import mock import pytest from _pytest.fixtures import SubRequest @@ -667,3 +669,16 @@ async def test_sync_client_inside_async_client(caplog: pytest.LogCaptureFixture) assert client.is_ready() assert await aclient.is_ready() assert "BlockingIOError: [Errno 35] Resource temporarily unavailable" not in caplog.text + + +def test_sync_client_connects_even_if_pypi_fails(): + with mock.patch.dict(os.environ, {"PYPI_PACKAGE_URL": "http://does-not-exist"}): + with weaviate.connect_to_local() as client: + assert client.is_ready() + + +@pytest.mark.asyncio +async def test_async_client_connects_even_if_pypi_fails(): + with mock.patch.dict(os.environ, {"PYPI_PACKAGE_URL": "http://does-not-exist"}): + async with weaviate.use_async_with_local() as client: + assert await client.is_ready() diff --git a/test/collection/test_config_methods.py b/test/collection/test_config_methods.py index 4edf76e47..fbc33b702 100644 --- a/test/collection/test_config_methods.py +++ b/test/collection/test_config_methods.py @@ -1,7 +1,6 @@ - -import pytest from weaviate.collections.classes.config_methods import _collection_configs_simple_from_json + def test_collection_config_simple_from_json_with_none_vectorizer_config() -> None: """Test that _collection_configs_simple_from_json handles None vectorizer config.""" schema = { @@ -10,9 +9,7 @@ def test_collection_config_simple_from_json_with_none_vectorizer_config() -> Non "class": "TestCollection", "vectorConfig": { "default": { - "vectorizer": { - "text2vec-transformers": None - }, + "vectorizer": {"text2vec-transformers": None}, "vectorIndexType": "hnsw", "vectorIndexConfig": { "skip": False, @@ -25,15 +22,15 @@ def test_collection_config_simple_from_json_with_none_vectorizer_config() -> Non "dynamicEfFactor": 8, "vectorCacheMaxObjects": 1000000000000, "flatSearchCutoff": 40000, - "distance": "cosine" - } + "distance": "cosine", + }, } }, "properties": [], "invertedIndexConfig": { - "bm25": {"b": 0.75, "k1": 1.2}, - "cleanupIntervalSeconds": 60, - "stopwords": {"preset": "en", "additions": None, "removals": None} + "bm25": {"b": 0.75, "k1": 1.2}, + "cleanupIntervalSeconds": 60, + "stopwords": {"preset": "en", "additions": None, "removals": None}, }, "replicationConfig": {"factor": 1, "deletionStrategy": "NoAutomatedResolution"}, "shardingConfig": { @@ -44,7 +41,7 @@ def test_collection_config_simple_from_json_with_none_vectorizer_config() -> Non "actualVirtualCount": 128, "key": "_id", "strategy": "hash", - "function": "murmur3" + "function": "murmur3", }, "vectorIndexType": "hnsw", "vectorIndexConfig": { @@ -58,8 +55,8 @@ def test_collection_config_simple_from_json_with_none_vectorizer_config() -> Non "dynamicEfFactor": 8, "vectorCacheMaxObjects": 1000000000000, "flatSearchCutoff": 40000, - "distance": "cosine" - } + "distance": "cosine", + }, } ] } diff --git a/weaviate/connect/v4.py b/weaviate/connect/v4.py index 0afb62ffe..2b47cface 100644 --- a/weaviate/connect/v4.py +++ b/weaviate/connect/v4.py @@ -738,15 +738,19 @@ def resp(res: Response) -> None: if is_weaviate_client_too_old(client_version, latest_version): _Warnings.weaviate_client_too_old_vs_latest(client_version, latest_version) - try: - if colour == "async": + if colour == "async": - async def _execute() -> None: + async def _execute() -> None: + try: async with AsyncClient() as client: res = await client.get(PYPI_PACKAGE_URL, timeout=self.timeout_config.init) return resp(res) + except RequestError: + pass # ignore any errors related to requests, it is a best-effort warning + + return _execute() - return _execute() + try: with Client() as client: res = client.get(PYPI_PACKAGE_URL, timeout=self.timeout_config.init) return resp(res)