-
Notifications
You must be signed in to change notification settings - Fork 234
fix: bugs when serialize union type #1655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: maxwelljin2 <gejin@berkeley.edu>
| ``` | ||
|
|
||
| !!! note | ||
| Currently, union type hints are not supported for serialization to protobuf formats. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any union type? or Union types of regular types are? Can u add tests for the exceptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add more tests. It should be any union type as union type doesn't have the from_protobuf method
Signed-off-by: maxwelljin2 <gejin@berkeley.edu>
|
Currently, the serialization for union type is only supported through |
JoanFM
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not answered what happens with Union of basic types
|
|
||
| !!! note | ||
| Currently, union type hints are not supported for serialization to protobuf formats. | ||
| Serialization to protobuf formats is not supported for union type hints. Please consider using JSON serialization as an alternative. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid the consideration, just inform
|
|
||
| from docarray.documents import TextDoc | ||
|
|
||
| class CustomDoc(BaseDoc): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about Union[int, float] or Union[int, str]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the testing, the Union with basic types should work in all serialization methods. Only the Union with document types will cause those issues.
Signed-off-by: maxwelljin2 <gejin@berkeley.edu>
Signed-off-by: maxwelljin2 <gejin@berkeley.edu>
Signed-off-by: Joan Fontanals <jfontanalsmartinez@gmail.com>
This bug is caused by the deserialization process. The deserialization function currently only checks the schema of the class, without specific information about the particular document type in the field of union type. To resolve this issue, we may need to modify the data storage. After discussing with Joan, we could temporarily remove support for the union type and add this info the document. Additionally, we provide users with a more informative error message.