From cf15efe2a28ecc44ebdc7cfdc6070eca266ce51f Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Fri, 13 Dec 2024 15:49:44 +0100 Subject: [PATCH 1/5] tenants: Add test to validate shard creation Add test case to ensure a shard is created after the tenant creation Signed-off-by: Rodrigo Lopez --- integration/test_tenants.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/integration/test_tenants.py b/integration/test_tenants.py index d8bb3b4be..762563b28 100644 --- a/integration/test_tenants.py +++ b/integration/test_tenants.py @@ -22,6 +22,20 @@ from weaviate.exceptions import WeaviateInvalidInputError, WeaviateUnsupportedFeatureError +def test_shards_on_tenants(client_factory: ClientFactory, collection_factory: CollectionFactory): + collection = collection_factory( + vectorizer_config=Configure.Vectorizer.none(), + multi_tenancy_config=Configure.multi_tenancy(enabled=True), + ) + collection.tenants.create(Tenant(name="tenant1")) + client = client_factory() + count = sum( + len(node.shards) for node in client.cluster.nodes(collection.name, output="verbose") + ) + + assert count == 1 + + @pytest.mark.parametrize("tenant", ["tenant1", Tenant(name="tenant1")]) def test_delete_by_id_tenant( collection_factory: CollectionFactory, tenant: Union[str, Tenant] From f464fcfbe6954a49b44e7ce0a3a0035afe3ec6f7 Mon Sep 17 00:00:00 2001 From: Dirk Kulawiak Date: Fri, 13 Dec 2024 16:33:47 +0100 Subject: [PATCH 2/5] Fix tests with httpx 0.28.1 --- integration/test_tenants.py | 10 ++++++---- weaviate/connect/v4.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/integration/test_tenants.py b/integration/test_tenants.py index 762563b28..5bfd04016 100644 --- a/integration/test_tenants.py +++ b/integration/test_tenants.py @@ -22,16 +22,18 @@ from weaviate.exceptions import WeaviateInvalidInputError, WeaviateUnsupportedFeatureError -def test_shards_on_tenants(client_factory: ClientFactory, collection_factory: CollectionFactory): +def test_shards_on_tenants( + client_factory: ClientFactory, collection_factory: CollectionFactory +) -> None: collection = collection_factory( vectorizer_config=Configure.Vectorizer.none(), multi_tenancy_config=Configure.multi_tenancy(enabled=True), ) collection.tenants.create(Tenant(name="tenant1")) client = client_factory() - count = sum( - len(node.shards) for node in client.cluster.nodes(collection.name, output="verbose") - ) + + nodes = client.cluster.nodes(collection.name, output="verbose") + count = sum(len(node.shards) for node in nodes) assert count == 1 diff --git a/weaviate/connect/v4.py b/weaviate/connect/v4.py index 2195f813d..b3bec7f8e 100644 --- a/weaviate/connect/v4.py +++ b/weaviate/connect/v4.py @@ -568,7 +568,7 @@ async def get( return await self.__send( "GET", url=self.url + self._api_version_path + path, - params=params if params is not None else {}, + params=params, error_msg=error_msg, status_codes=status_codes, ) From 7378f027fa42247c0c054293eae4d7c37d5f36c2 Mon Sep 17 00:00:00 2001 From: Dirk Kulawiak Date: Fri, 13 Dec 2024 16:34:39 +0100 Subject: [PATCH 3/5] set minimum version --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 21aa664cd..85d7e05e4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,7 +31,7 @@ packages = platforms = any include_package_data = True install_requires = - httpx>=0.26.0,<0.29.0 + httpx>=0.26.0,<0.28.0 validators==0.34.0 authlib>=1.2.1,<1.3.2 pydantic>=2.8.0,<3.0.0 From 355cba0533d88effb348f6145e85ca94a83c538b Mon Sep 17 00:00:00 2001 From: Dirk Kulawiak Date: Fri, 13 Dec 2024 16:42:26 +0100 Subject: [PATCH 4/5] Better solution. Explicitly add params --- weaviate/collections/cluster/cluster.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/weaviate/collections/cluster/cluster.py b/weaviate/collections/cluster/cluster.py index d0ca1cdb5..32b94d4a2 100644 --- a/weaviate/collections/cluster/cluster.py +++ b/weaviate/collections/cluster/cluster.py @@ -1,3 +1,4 @@ +from httpx import Response from weaviate.connect import ConnectionV4 @@ -75,12 +76,15 @@ async def nodes( If the response is empty. """ path = "/nodes" + params = None if collection is not None: path += "/" + _capitalize_first_letter(collection) if output is not None: - path += f"?output={output}" + params = {"output": output} - response = await self._connection.get(path=path, error_msg="Get nodes status failed") + response: Response = await self._connection.get( + path=path, params=params, error_msg="Get nodes status failed" + ) response_typed = _decode_json_response_dict(response, "Nodes status") assert response_typed is not None From 095af3be1beecda3829616f4a3a2ae049031ae28 Mon Sep 17 00:00:00 2001 From: Tommy Smith Date: Fri, 13 Dec 2024 16:17:52 +0000 Subject: [PATCH 5/5] Relax restriction on httpx to include `0.28` --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 85d7e05e4..21aa664cd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,7 +31,7 @@ packages = platforms = any include_package_data = True install_requires = - httpx>=0.26.0,<0.28.0 + httpx>=0.26.0,<0.29.0 validators==0.34.0 authlib>=1.2.1,<1.3.2 pydantic>=2.8.0,<3.0.0