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: keep _metadata when serializing to dict and json #443

Merged
merged 6 commits into from
Jul 19, 2022

Conversation

JohannesMessner
Copy link
Member

@JohannesMessner JohannesMessner commented Jul 18, 2022

This bug is the root cause of multi-modal documents not working after being (de)serilaized from/to json or dict.
Details here: #429

Better multi-modal support (#425) partially depends on this.

There seems to be no super elegant way of solving this with pydantic, based on this and this.

I see two options:

  1. make metadata public, so rename _metadata -> metadata
  2. set and validate _metadata manually

In order not to change the pydantic model of Document, this PR implements option 2.

@codecov
Copy link

codecov bot commented Jul 18, 2022

Codecov Report

Merging #443 (615f3ce) into main (b8ba0f8) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #443      +/-   ##
==========================================
- Coverage   86.62%   86.61%   -0.02%     
==========================================
  Files         134      134              
  Lines        6477     6486       +9     
==========================================
+ Hits         5611     5618       +7     
- Misses        866      868       +2     
Flag Coverage Δ
docarray 86.61% <100.00%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
docarray/__init__.py 75.00% <100.00%> (ø)
docarray/document/pydantic_model.py 98.03% <100.00%> (+0.42%) ⬆️
docarray/helper.py 81.90% <0.00%> (-0.91%) ⬇️

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 69926d4...615f3ce. Read the comment docs.

@JohannesMessner JohannesMessner marked this pull request as ready for review July 19, 2022 07:50
@JohannesMessner JohannesMessner merged commit 64721a6 into main Jul 19, 2022
@JohannesMessner JohannesMessner deleted the fix-metadata-serialization branch July 19, 2022 14:17
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.

2 participants