Skip to content

Assertion Error when running the server and client locally #69

Description

@AaronDinesh

Hello! I am currently using vectordb in a personal project and wanted to get the server and client running. I started the server as per the instruction in the README, similarly with the client. The code I use is below

# server.py
from docarray import DocList
import numpy as np
from vectordb import InMemoryExactNNVectorDB, HNSWVectorDB
from docarray import BaseDoc
from docarray.typing import NdArray

class ToyDoc(BaseDoc):
  text: str = ''
  embedding: NdArray[128]

# Specify your workspace path
db = InMemoryExactNNVectorDB[ToyDoc](workspace='./workspace_path')

# Index a list of documents with random embeddings
doc_list = [ToyDoc(text=f'toy doc {i}', embedding=np.random.rand(128)) for i in range(1000)]
db.index(inputs=DocList[ToyDoc](doc_list))

with db.serve(protocol='grpc', port=12345, replicas=1, shards=1) as service:
   service.block()
# client.py
from docarray import BaseDoc
from docarray.typing import NdArray

class ToyDoc(BaseDoc):
  text: str = ''
  embedding: NdArray[128]


from vectordb import Client

# Instantiate a client connected to the server. In practice, replace 0.0.0.0 to the server IP address.
client = Client[ToyDoc](address='grpc://0.0.0.0:12345')

# Perform a search query
results = client.search(inputs=DocList[ToyDoc]([query]), limit=10)

However when I run the server and the client I get an AssertionError from the server

# Last line of server output

           assert len(docs) == len(matched_documents) == len(matched_scores)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       AssertionError

Here is the full error from the server

ERROR  indexer/rep-0@28106 AssertionError()                                                                                              [08/06/24 13:52:39]
        add "--quiet-error" to suppress the exception details
       Traceback (most recent call last):
         File "/home/ubuntu/miniconda3/envs/woc/lib/python3.11/site-packages/jina/serve/runtimes/worker/request_handling.py", line 1106,
       in process_data
           result = await self.handle(
                    ^^^^^^^^^^^^^^^^^^
         File "/home/ubuntu/miniconda3/envs/woc/lib/python3.11/site-packages/jina/serve/runtimes/worker/request_handling.py", line 720,
       in handle
           return_data = await self._executor.__acall__(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         File "/home/ubuntu/miniconda3/envs/woc/lib/python3.11/site-packages/jina/serve/executors/__init__.py", line 749, in __acall__
           return await self.__acall_endpoint__(req_endpoint, **kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         File "/home/ubuntu/miniconda3/envs/woc/lib/python3.11/site-packages/jina/serve/executors/__init__.py", line 881, in
       __acall_endpoint__
           return await exec_func(
                  ^^^^^^^^^^^^^^^^
         File "/home/ubuntu/miniconda3/envs/woc/lib/python3.11/site-packages/jina/serve/executors/__init__.py", line 839, in exec_func
           return await get_or_reuse_loop().run_in_executor(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         File "/home/ubuntu/miniconda3/envs/woc/lib/python3.11/concurrent/futures/thread.py", line 58, in run
           result = self.fn(*self.args, **self.kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         File "/home/ubuntu/miniconda3/envs/woc/lib/python3.11/site-packages/jina/serve/executors/decorators.py", line 325, in
       arg_wrapper
           return fn(executor_instance, *args, **kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         File "/home/ubuntu/miniconda3/envs/woc/lib/python3.11/site-packages/vectordb/db/executors/inmemory_exact_indexer.py", line 54,
       in search
           return self._search(docs, *args, **kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         File "/home/ubuntu/miniconda3/envs/woc/lib/python3.11/site-packages/vectordb/db/executors/inmemory_exact_indexer.py", line 42,
       in _search
           assert len(docs) == len(matched_documents) == len(matched_scores)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       AssertionError

Is there something I am missing? Or is this a known issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions