Skip to content

Commit b1599a8

Browse files
committed
Refactor
1 parent 6eb0ad9 commit b1599a8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

weaviate/collections/batch/grpc_batch_objects.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,14 @@ def __init__(self, connection: ConnectionV4, consistency_level: Optional[Consist
4949

5050
def __grpc_objects(self, objects: List[_BatchObject]) -> List[batch_pb2.BatchObject]:
5151
def pack_vector(vector: Any) -> bytes:
52-
vector_list = _get_vector_v4(vector)
53-
return struct.pack("{}f".format(len(vector_list)), *vector_list)
52+
return struct.pack("{}f".format(len(vector)), *vector)
5453

5554
return [
5655
batch_pb2.BatchObject(
5756
collection=obj.collection,
5857
vector_bytes=(
5958
pack_vector(obj.vector)
60-
if obj.vector is not None and not isinstance(obj.vector, dict)
59+
if obj.vector is not None and isinstance(obj.vector, list)
6160
else None
6261
),
6362
uuid=str(obj.uuid) if obj.uuid is not None else str(uuid_package.uuid4()),

weaviate/collections/data/data.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,12 @@ async def insert_many(
363363
(
364364
_BatchObject(
365365
collection=self.name,
366-
vector=obj.vector,
366+
vector=(
367+
obj.vector
368+
if obj.vector is None
369+
or isinstance(obj.vector, dict)
370+
else _get_vector_v4(obj.vector)
371+
),
367372
uuid=str(obj.uuid if obj.uuid is not None else uuid_package.uuid4()),
368373
properties=cast(dict, obj.properties),
369374
tenant=self._tenant,

0 commit comments

Comments
 (0)