Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

to_protobuf does not work for Stacked DocumentArray in some cases #1069

Closed

Description

@Jackmin801

script.py

import torch
from typing import Optional
from docarray import BaseDocument, DocumentArray
from docarray.typing import TorchTensor
from docarray.documents import Text as BaseText, Image


class Tokens(BaseDocument):
    input_ids: TorchTensor[48]
    attention_mask: TorchTensor


class Text(BaseText):
    tokens: Optional[Tokens]


class PairTextImage(BaseDocument):
    text: Text
    image: Image


def get_da(N: Optional[int] = None):
    da = DocumentArray[PairTextImage](
        PairTextImage(
            text=Text(
                text=str(i),
                tokens=Tokens(
                    input_ids=torch.randn(48), attention_mask=torch.randn(48)
                ),
            ),
            image=Image(url=f"Images/{i}.png"),
        )
        for i in range(N)
    )
    return da.stack()

da = get_da(10)
da.to_protobuf()

Output

Traceback (most recent call last):
  File "tiger.py", line 38, in <module>
    da.to_protobuf()
  File "/home/jackmin/Documents/da-testing/docarray/docarray/array/array_stacked.py", line 263, in to_protobuf
    document_array=DocumentArrayProto(stack=column.to_protobuf())
  File "/home/jackmin/Documents/da-testing/docarray/docarray/array/array_stacked.py", line 263, in to_protobuf
    document_array=DocumentArrayProto(stack=column.to_protobuf())
ValueError: Protocol message DocumentArrayProto has no "stack" field.

Activity

  1. changed the title [-]`to_protobuf` does not work for TorchTensor[/-] [+]`to_protobuf` does not work for Stacked DocumentArray[/+] on Feb 1, 2023
  2. changed the title [-]`to_protobuf` does not work for Stacked DocumentArray[/-] [+]`to_protobuf` does not work for Stacked DocumentArray in some cases[/+] on Feb 1, 2023
  3. changed the title [-]`to_protobuf` does not work for Stacked DocumentArray in some cases[/-] [+]`to_protobuf` does not work for DocumentArray in some cases[/+] on Feb 1, 2023
  4. changed the title [-]`to_protobuf` does not work for DocumentArray in some cases[/-] [+]`to_protobuf` does not work for Stacked DocumentArray in some cases[/+] on Feb 1, 2023
  5. JoanFM commented on Feb 1, 2023

    @JoanFM
    Member

    This needs to be handled

  6. moved this from Todo to tech debt but not really in DocArray backlogon Feb 3, 2023
  7. self-assigned this
    on Feb 6, 2023
  8. moved this from tech debt but not really to In Progress in DocArray backlogon Feb 6, 2023
  9. moved this from In Progress to Done in DocArray backlogon Feb 7, 2023
  10. JoanFM commented on Feb 7, 2023

    @JoanFM
    Member

    This seems to work right now! I believe @JohannesMessner PR fixed it

  11. JohannesMessner commented on Feb 7, 2023

    @JohannesMessner
    Member

    This should be the PR that fixed it, thanks to the refactoring of the DocumentArrayStacked columns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions