Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions integration/test_client.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
23 changes: 10 additions & 13 deletions test/collection/test_config_methods.py
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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,
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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",
},
}
]
}
Expand Down
12 changes: 8 additions & 4 deletions weaviate/connect/v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down