-
Notifications
You must be signed in to change notification settings - Fork 238
Milvus misses implementation of __len__ #884
Copy link
Copy link
Closed
Description
Describe the bug
Milvus Storage is missing the implementation of __len__ and therefore uses the __len__ function from docarray/array/storage/base/seqlike.py which depends on offset2id attribute. This results in wrong length when list like behaviour is disabled.
To Reproduce
from docarray import Document, DocumentArray
def test_persistence_2(docs):
da1 = DocumentArray(storage='milvus', config={'collection_name': 'test9040f', 'distance': 'L2', 'n_dim': 128})
with da1:
da1.extend(docs)
print(f"len(da1) = {len(da1)}")
da2 = DocumentArray(storage='milvus', config={'collection_name': 'test7300d', 'distance': 'L2', 'n_dim': 128, 'list_like': False})
with da2:
da2.extend(docs)
print(f"len(da2) = {len(da2)}")
with da1, da2:
assert len(da2) == len(docs)
if __name__ == '__main__':
test_persistence_2([Document() for _ in range(10)])error message:
len(da1) = 20
len(da2) = 0
Traceback (most recent call last):
File "/Users/charlottegerhaher/Library/Application Support/JetBrains/PyCharm2022.2/scratches/scratch_3.py", line 20, in <module>
test_persistence_2([Document() for _ in range(10)])
File "/Users/charlottegerhaher/Library/Application Support/JetBrains/PyCharm2022.2/scratches/scratch_3.py", line 16, in test_persistence_2
assert len(da2) == len(docs)
AssertionError
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels