Context
When a DA is serialize then deserialize in protobuf, if the tags are int then there are converted to float.
This is an issue when using docarray with Jina. Especially for VectorDB indexer. For instance with the WeaviateIndexer:
from jina import Flow
from docarray import Document, DocumentArray
f = Flow().add(
uses=WeaviateIndexer,
uses_with={
'name': 'Test',
'n_dim': 3,
'columns': [('price', 'int')],
},
)
docs = DocumentArray(
[
Document(id=f'r{i}', embedding=np.random.rand(3), tags={'price': int(i)})
for i in range(50)
]
)
with f:
f.index(docs)
This will fail because the Weaviate backend expect the docs to have the tags price as int but the Executor will receive them as float because of the protobuff de/serialization.
code to reproduce:
see the following code to reproduce
from docarray import DocumentArray, Document
def test_type_protobuf():
da_int = DocumentArray([Document(tags={'price': i}) for i in range(10)])
da_receive = DocumentArray.from_protobuf(da_int.to_protobuf())
for doc in da_receive:
assert type(doc.tags['price']) == int
Output:
FAILED scratch_1.py::test_type_protobuf - AssertionError: assert <class 'float'> == int
Context
When a DA is serialize then deserialize in protobuf, if the tags are
intthen there are converted tofloat.This is an issue when using docarray with Jina. Especially for VectorDB indexer. For instance with the WeaviateIndexer:
This will fail because the Weaviate backend expect the docs to have the tags price as
intbut the Executor will receive them asfloatbecause of the protobuff de/serialization.code to reproduce:
see the following code to reproduce
Output: