Skip to content

fix: from proto for nested List and Dict#1471

Merged
JoanFM merged 6 commits into
mainfrom
fix-from-proto
Apr 27, 2023
Merged

fix: from proto for nested List and Dict#1471
JoanFM merged 6 commits into
mainfrom
fix-from-proto

Conversation

@samsja

@samsja samsja commented Apr 27, 2023

Copy link
Copy Markdown
Member

Context

This pr fixes several bugs related to proto.

  • Nested typed List/Set/Tuple with doc inside are now working
  • Nested typed Dict with doc inside are now working
  • raise informative error message when a dict does not have a string field but to_protobuf is called

Example

    from typing import List

    from docarray import BaseDoc, DocList
    from docarray.documents import TextDoc

    class TextDocWithId(TextDoc):
        id: str

    class ResultTestDoc(BaseDoc):
        matches: List[TextDocWithId]

    da = DocList[ResultTestDoc](
        [
            ResultTestDoc(matches=[TextDocWithId(id=f'{i}') for _ in range(10)])
            for i in range(10)
        ]
    )

    DocList[ResultTestDoc].from_protobuf(da.to_protobuf())

samsja added 3 commits April 27, 2023 16:08
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
@samsja samsja requested a review from JoanFM April 27, 2023 14:35
@samsja samsja marked this pull request as ready for review April 27, 2023 14:35
@JoanFM JoanFM changed the title fro: from proto for nested Dict fix: from proto for nested Dict Apr 27, 2023
@JoanFM JoanFM changed the title fix: from proto for nested Dict fix: from proto for nested List Apr 27, 2023
samsja added 3 commits April 27, 2023 16:55
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
@github-actions

Copy link
Copy Markdown

📝 Docs are deployed on https://ft-fix-from-proto--jina-docs.netlify.app 🎉

@JoanFM JoanFM changed the title fix: from proto for nested List fix: from proto for nested List and Dict Apr 27, 2023
@JoanFM JoanFM merged commit 815ba88 into main Apr 27, 2023
@JoanFM JoanFM deleted the fix-from-proto branch April 27, 2023 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants