Skip to content

fix: skip doc attributes in __annotations__ but not in __fields__ #1777

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

Merged
merged 1 commit into from
Sep 7, 2023

Conversation

JoanFM
Copy link
Member

@JoanFM JoanFM commented Sep 6, 2023

Porting fix jina-ai/serve#6035 to docarray

Signed-off-by: Joan Fontanals Martinez <[email protected]>
@JoanFM JoanFM force-pushed the fix-skip-annotations-not-in-field branch from e813ede to eea8c76 Compare September 6, 2023 15:33
@NarekA
Copy link

NarekA commented Sep 6, 2023

Thanks for doing this!

@@ -51,6 +51,8 @@ class MyDoc(BaseDoc):
"""
fields: Dict[str, Any] = {}
for field_name, field in model.__annotations__.items():
if field_name not in model.__fields__:
continue
field_info = model.__fields__[field_name].field_info
Copy link

@NarekA NarekA Sep 6, 2023

Choose a reason for hiding this comment

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

FWIW: It might be a good idea to use something like pydash.get here in case traversal breaks at a different location.

@codecov
Copy link

codecov bot commented Sep 6, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (189ff63) 84.99% compared to head (eea8c76) 85.01%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1777      +/-   ##
==========================================
+ Coverage   84.99%   85.01%   +0.01%     
==========================================
  Files         134      134              
  Lines        8845     8847       +2     
==========================================
+ Hits         7518     7521       +3     
+ Misses       1327     1326       -1     
Flag Coverage Δ
docarray 85.01% <100.00%> (+0.01%) ⬆️

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

Files Changed Coverage Δ
docarray/utils/create_dynamic_doc_class.py 84.00% <100.00%> (+0.32%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JoanFM
Copy link
Member Author

JoanFM commented Sep 6, 2023

Actually, @NarekA it would be nice if you could open this PR on your own so that we can properly credit the actual contributor. I just did not want to annoy you with it, but since you have already seen this and you are now aware of this need, it may be good to have this.

Could you open such a PR?

@NarekA
Copy link

NarekA commented Sep 6, 2023

Opening a new PR now

@NarekA
Copy link

NarekA commented Sep 6, 2023

Here: #1779

@JoanFM JoanFM closed this Sep 6, 2023
@JoanFM JoanFM reopened this Sep 6, 2023
@github-actions
Copy link

github-actions bot commented Sep 6, 2023

📝 Docs are deployed on https://ft-fix-skip-annotations-not-in-field--jina-docs.netlify.app 🎉

@JoanFM JoanFM merged commit fb17456 into main Sep 7, 2023
@JoanFM JoanFM deleted the fix-skip-annotations-not-in-field branch September 7, 2023 07:07
@JoanFM JoanFM mentioned this pull request Sep 7, 2023
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