-
Notifications
You must be signed in to change notification settings - Fork 222
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
fix(pydantic): turn on pydantic smart union #73
Conversation
Codecov Report
@@ Coverage Diff @@
## main #73 +/- ##
=======================================
Coverage 83.06% 83.07%
=======================================
Files 70 70
Lines 3402 3404 +2
=======================================
+ Hits 2826 2828 +2
Misses 576 576
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
docarray/document/pydantic_model.py
Outdated
@@ -38,7 +38,7 @@ class PydanticDocument(BaseModel): | |||
text: Optional[str] | |||
weight: Optional[float] | |||
uri: Optional[str] | |||
tags: Optional[Dict[str, '_StructValueType']] | |||
tags: Optional[Dict[str, Any]] |
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.
This however makes tags
unschema
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.
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 think is right having tags unschema, it is the free part of Document
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.
but the "free-part" still have to be a valid JSON
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.
the right way is to turn on pydantic smart union, as in https://pydantic-docs.helpmanual.io/usage/model_config/#smart-union
the original title of the PR is misleading, the default behavior is not "smart union" according to https://pydantic-docs.helpmanual.io/usage/model_config/#smart-union This PR in fact turns on the "smart union". |
attempt to address #72