Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d43057b
feat: json and dict for docvec
JohannesMessner May 22, 2023
c45bfca
test: add tests
JohannesMessner May 22, 2023
564d144
test: add docvec to dict test
JohannesMessner May 22, 2023
76f9c8e
feat: to from dataframe for docvec
JohannesMessner May 22, 2023
73a1ac7
test: dataframe docvec tests
JohannesMessner May 22, 2023
f83fb4f
feat: to from csv for docvec
JohannesMessner May 22, 2023
ca8dc12
test: test csv with docvec
JohannesMessner May 22, 2023
2b52b1e
Merge branch 'main' into feat-docvec-io
JohannesMessner Jun 14, 2023
b115637
feat: pickle serialization for docvec
JohannesMessner Jun 14, 2023
bd86985
feat: protbuf array serialization for docvec
JohannesMessner Jun 14, 2023
c280ff2
test: test base64 deser for docvec
JohannesMessner Jun 14, 2023
ad881cf
test: test save and load for docvec
JohannesMessner Jun 14, 2023
4b1b533
feat: docvec json column wise
JohannesMessner Jun 19, 2023
60e651e
Merge branch 'main' into feat-docvec-io
JohannesMessner Jun 19, 2023
f9c97ec
Merge branch 'main' into feat-docvec-io
JohannesMessner Jun 20, 2023
0603fc5
test: add test for docvec json
JohannesMessner Jun 20, 2023
c6ace8e
test: add tensor type arg
JohannesMessner Jun 20, 2023
51719b2
fix: mypy stuff
JohannesMessner Jun 26, 2023
ad5f5bd
fix: raising of error when needed
JohannesMessner Jun 26, 2023
200dbac
fix: more exception raising
JohannesMessner Jun 26, 2023
8d1f446
fix: mypy
JohannesMessner Jun 26, 2023
6815720
refactor: don't expose to/from csv for docvec
JohannesMessner Jun 26, 2023
6b5ddc7
test: adjust tests
JohannesMessner Jun 26, 2023
587c20a
docs: add documentation for docvec io
JohannesMessner Jun 27, 2023
663f17d
Merge branch 'main' into feat-docvec-io
JohannesMessner Jun 27, 2023
7d035fb
Merge branch 'main' into feat-docvec-io
JohannesMessner Jun 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: protbuf array serialization for docvec
Signed-off-by: Johannes Messner <[email protected]>
  • Loading branch information
JohannesMessner committed Jun 14, 2023
commit bd86985eac44a5a2707141011def112e1e541461
6 changes: 6 additions & 0 deletions docarray/array/doc_list/doc_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ def from_protobuf(cls: Type[T], pb_msg: 'DocListProto') -> T:
"""
return super().from_protobuf(pb_msg)

@classmethod
def _get_proto_class(cls: Type[T]):
from docarray.proto import DocListProto

return DocListProto

@overload
def __getitem__(self, item: SupportsIndex) -> T_doc:
...
Expand Down
13 changes: 8 additions & 5 deletions docarray/array/doc_list/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,11 @@ def _stream_header(self) -> bytes:
num_docs_as_bytes = len(self).to_bytes(8, 'big', signed=False)
return version_byte + num_docs_as_bytes

@classmethod
@abstractmethod
def _get_proto_class(cls: Type[T]):
...

@classmethod
def _load_binary_all(
cls: Type[T],
Expand Down Expand Up @@ -594,12 +599,10 @@ def _load_binary_all(
compress = None

if protocol is not None and protocol == 'protobuf-array':
from docarray.proto import DocListProto

dap = DocListProto()
dap.ParseFromString(d)
proto = cls._get_proto_class()()
proto.ParseFromString(d)

return cls.from_protobuf(dap)
return cls.from_protobuf(proto)
elif protocol is not None and protocol == 'pickle-array':
return pickle.loads(d)

Expand Down
6 changes: 6 additions & 0 deletions docarray/array/doc_vec/doc_vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,12 @@ def __len__(self):
# IO related #
####################

@classmethod
def _get_proto_class(cls: Type[T]):
from docarray.proto import DocVecProto

return DocVecProto

def _docarray_to_json_compatible(self) -> List[Dict]:
return [doc._docarray_to_json_compatible() for doc in self]

Expand Down