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: unwanted coercion in to_pydantic_model #949

Merged
merged 7 commits into from Dec 17, 2022
Merged

Conversation

JohannesMessner
Copy link
Member

Goals:

This raises the required pydantic version to fix unwanted type coercion in doc.to_pydantic_model(), and by extension, in doc.to_dict().

Before:

from jina import Document

d = Document()
d.tags['title'] = 'Infinity'

print(d.to_pydantic_model())
id='f3fbf26990ef007fe577994b634140db' parent_id=None granularity=None adjacency=None blob=None tensor=None mime_type=None text=None weight=None uri=None tags={'title': 'inf'} offset=None location=None embedding=None modality=None evaluations=None scores=None chunks=None matches=None

Note tags={'title': 'inf'}, it coerced "Infinity" to inf, not what we want.
After:

from jina import Document

d = Document()
d.tags['title'] = 'Infinity'

print(d.to_pydantic_model())
id='f3fbf26990ef007fe577994b634140db' parent_id=None granularity=None adjacency=None blob=None tensor=None mime_type=None text=None weight=None uri=None tags={'title': 'Infinity'} offset=None location=None embedding=None modality=None evaluations=None scores=None chunks=None matches=None

Note tags={'title': 'Infinity'}, no unwanted coercion.

Signed-off-by: Johannes Messner <messnerjo@gmail.com>
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
# Conflicts:
#	docarray/array/storage/milvus/seqlike.py
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
@JohannesMessner JohannesMessner marked this pull request as ready for review December 15, 2022 10:34
@codecov-commenter
Copy link

codecov-commenter commented Dec 15, 2022

Codecov Report

Base: 85.14% // Head: 85.21% // Increases project coverage by +0.06% 🎉

Coverage data is based on head (0e5e677) compared to base (6bbcde8).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #949      +/-   ##
==========================================
+ Coverage   85.14%   85.21%   +0.06%     
==========================================
  Files         155      155              
  Lines        8018     8048      +30     
==========================================
+ Hits         6827     6858      +31     
+ Misses       1191     1190       -1     
Flag Coverage Δ
docarray 85.21% <ø> (+0.06%) ⬆️

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

Impacted Files Coverage Δ
docarray/array/mixins/traverse.py 96.58% <0.00%> (-0.03%) ⬇️
docarray/document/strawberry_type.py 100.00% <0.00%> (ø)
docarray/array/storage/memory/backend.py 100.00% <0.00%> (ø)
docarray/array/mixins/io/binary.py 99.35% <0.00%> (+<0.01%) ⬆️
docarray/base.py 98.76% <0.00%> (+0.01%) ⬆️
docarray/array/storage/redis/backend.py 97.52% <0.00%> (+0.02%) ⬆️
docarray/array/storage/milvus/backend.py 98.24% <0.00%> (+0.02%) ⬆️
docarray/array/storage/elastic/backend.py 97.08% <0.00%> (+0.02%) ⬆️
docarray/array/storage/opensearch/backend.py 95.89% <0.00%> (+0.02%) ⬆️
docarray/array/storage/annlite/backend.py 97.46% <0.00%> (+0.03%) ⬆️
... and 14 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@JoanFM JoanFM left a comment

Choose a reason for hiding this comment

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

Can we add a test showing the behavior is correct?

Signed-off-by: Johannes Messner <messnerjo@gmail.com>
@JoanFM JoanFM merged commit 1443376 into main Dec 17, 2022
@JoanFM JoanFM deleted the fix-pydantic-version branch December 17, 2022 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants