weaviate/weaviate-python-client

Python client fails to retrieve nodes information with output verbose when one of the nodes is in TIMEOUT state

Closed this issue · 0 comments

Some of the function tests were consistenly failing with the following traceback:

=================================== FAILURES ===================================
____________________ test_multitenant_creation[rf-1-sync-1] ____________________

multitenant_class = (<weaviate.collections.collection.sync.Collection object at 0x11195ad70>, <weaviate.client.WeaviateClient object at 0x112523d30>)
number_of_tenants = 1

    @pytest.mark.parametrize("number_of_tenants", [1, 100])
    def test_multitenant_creation(multitenant_class, number_of_tenants):
        collection, client = multitenant_class
        collection.tenants.create(
            [
                Tenant(
                    name=f"Tenant-With_Very-Very-_Very-Very_Very-Very-Very---Long-Name-{i}"
                )
                for i in range(number_of_tenants)
            ]
        )
        count = 0
        wait_for_tenant(collection, number_of_tenants)
>       for node in client.cluster.nodes(collection.name, output="verbose"):

tests/core/multitenant_test.py:181: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv/lib/python3.10/site-packages/weaviate/syncify.py:23: in sync_method
    return _EventLoopSingleton.get_instance().run_until_complete(
.venv/lib/python3.10/site-packages/weaviate/event_loop.py:40: in run_until_complete
    return fut.result()
../../.pyenv/versions/3.10.12/lib/python3.10/concurrent/futures/_base.py:458: in result
    return self.__get_result()
../../.pyenv/versions/3.10.12/lib/python3.10/concurrent/futures/_base.py:403: in __get_result
    raise self._exception
.venv/lib/python3.10/site-packages/weaviate/collections/cluster/cluster.py:95: in nodes
    return _ConvertFromREST.nodes_verbose(nodes)
.venv/lib/python3.10/site-packages/weaviate/collections/classes/cluster.py:49: in nodes_verbose
    return [
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

.0 = <list_iterator object at 0x1125e0430>

    return [
        Node(
>           git_hash=node["gitHash"],
            name=node["name"],
            shards=(
                [
                    Shard(
                        collection=shard["class"],
                        name=shard["name"],
                        node=node["name"],
                        object_count=shard["objectCount"],
                        vector_indexing_status=shard["vectorIndexingStatus"],
                        vector_queue_length=shard["vectorQueueLength"],
                        compressed=shard["compressed"],
                        loaded=shard.get("loaded"),
                    )
                    for shard in cast(List[ShardREST], node["shards"])
                ]
                if "shards" in node and node["shards"] is not None
                else []
            ),
            stats=(
                Stats(
                    object_count=node["stats"]["objectCount"],
                    shard_count=node["stats"]["shardCount"],
                )
                if "stats" in node
                else Stats(
                    object_count=0,
                    shard_count=0,
                )
            ),
            status=node["status"],
            version=node["version"],
        )
        for node in nodes
    ]
E   KeyError: 'gitHash'

.venv/lib/python3.10/site-packages/weaviate/collections/classes/cluster.py:51: KeyError

When digging into the values of the nodes, it was found that when a node is in TIMEOUT state no other information is returned:

    {
      "name": "weaviate-8",
      "shards": null,
      "status": "TIMEOUT"
    },

Therefore, the following code fails as there is no gitHash index to return.