Skip to content
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

Merged
merged 3 commits into from
Jan 23, 2022
Merged

Conversation

numb3r3
Copy link
Contributor

@numb3r3 numb3r3 commented Jan 21, 2022

attempt to address #72

@codecov
Copy link

codecov bot commented Jan 21, 2022

Codecov Report

Merging #73 (359328c) into main (66ceeda) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #73   +/-   ##
=======================================
  Coverage   83.06%   83.07%           
=======================================
  Files          70       70           
  Lines        3402     3404    +2     
=======================================
+ Hits         2826     2828    +2     
  Misses        576      576           
Flag Coverage Δ
docarray 83.07% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
docarray/__init__.py 100.00% <100.00%> (ø)
docarray/document/pydantic_model.py 95.74% <100.00%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecf89c4...359328c. Read the comment docs.

@@ -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]]
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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

Copy link
Member

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

Copy link
Member

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

@hanxiao hanxiao changed the title fix(pydantic): disable smart union fix(pydantic): turn on pydantic smart union Jan 23, 2022
@hanxiao
Copy link
Member

hanxiao commented Jan 23, 2022

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".

@hanxiao hanxiao merged commit 412930d into main Jan 23, 2022
@hanxiao hanxiao deleted the fix-pydantic-union branch January 23, 2022 09:40
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.

None yet

3 participants