-
Notifications
You must be signed in to change notification settings - Fork 234
feat: nested attribute access in find()
#1176
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
Conversation
docarray/utils/find.py
Outdated
| emb = embedding_type._docarray_stack(emb_list) | ||
| elif isinstance(data, DocumentArrayStacked): | ||
| emb = getattr(data, embedding_field) | ||
| emb = next(AnyDocumentArray._traverse(data, embedding_field)) |
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.
not sure to understand why it is next here
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.
For DocumentArray stacked, the _traverse will yield one stacked tensor, by calling next() on it, I want to get that one tensor. I think this would be the same as calling list(AnyDocumentArray._traverse(data, embedding_field))[0].
docarray/helper.py
Outdated
|
|
||
| def _get_field_type_by_access_path( | ||
| doc_type: Type['BaseDocument'], access_path: 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.
-> Optional[Type]?
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.
applied!
Signed-off-by: anna-charlotte <[email protected]>
Signed-off-by: anna-charlotte <[email protected]>
Signed-off-by: anna-charlotte <[email protected]>
Signed-off-by: anna-charlotte <[email protected]>
Signed-off-by: anna-charlotte <[email protected]>
Signed-off-by: anna-charlotte <[email protected]>
Signed-off-by: anna-charlotte <[email protected]>
Signed-off-by: anna-charlotte <[email protected]>
Signed-off-by: anna-charlotte <[email protected]>
Signed-off-by: anna-charlotte <[email protected]>
Signed-off-by: anna-charlotte <[email protected]>
Signed-off-by: anna-charlotte <[email protected]>
68af091 to
8400ed4
Compare
|
📝 Docs are deployed on https://ft-feat-find-nested-access--jina-docs.netlify.app 🎉 |
* test: add test for find on nested attribute Signed-off-by: anna-charlotte <[email protected]> * test: add test for nested attr in stacked da Signed-off-by: anna-charlotte <[email protected]> * fix: nested access Signed-off-by: anna-charlotte <[email protected]> * fix: mypy Signed-off-by: anna-charlotte <[email protected]> * fix: field type by access path for da Signed-off-by: anna-charlotte <[email protected]> * fix: clean up Signed-off-by: anna-charlotte <[email protected]> * fix: move get field type by access path Signed-off-by: anna-charlotte <[email protected]> * fix: imports Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestion and fix import Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestion from code review Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestion from code review Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestions Signed-off-by: anna-charlotte <[email protected]> --------- Signed-off-by: anna-charlotte <[email protected]> Signed-off-by: Arnav Zutshi <[email protected]>
* test: add test for find on nested attribute Signed-off-by: anna-charlotte <[email protected]> * test: add test for nested attr in stacked da Signed-off-by: anna-charlotte <[email protected]> * fix: nested access Signed-off-by: anna-charlotte <[email protected]> * fix: mypy Signed-off-by: anna-charlotte <[email protected]> * fix: field type by access path for da Signed-off-by: anna-charlotte <[email protected]> * fix: clean up Signed-off-by: anna-charlotte <[email protected]> * fix: move get field type by access path Signed-off-by: anna-charlotte <[email protected]> * fix: imports Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestion and fix import Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestion from code review Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestion from code review Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestions Signed-off-by: anna-charlotte <[email protected]> --------- Signed-off-by: anna-charlotte <[email protected]>
* test: add test for find on nested attribute Signed-off-by: anna-charlotte <[email protected]> * test: add test for nested attr in stacked da Signed-off-by: anna-charlotte <[email protected]> * fix: nested access Signed-off-by: anna-charlotte <[email protected]> * fix: mypy Signed-off-by: anna-charlotte <[email protected]> * fix: field type by access path for da Signed-off-by: anna-charlotte <[email protected]> * fix: clean up Signed-off-by: anna-charlotte <[email protected]> * fix: move get field type by access path Signed-off-by: anna-charlotte <[email protected]> * fix: imports Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestion and fix import Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestion from code review Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestion from code review Signed-off-by: anna-charlotte <[email protected]> * fix: apply suggestions Signed-off-by: anna-charlotte <[email protected]> --------- Signed-off-by: anna-charlotte <[email protected]>
Goals:
allow nested attribute access in
find(), which currently isn't supported yet. Nested access will be possible by '__'-separated access paths.Example: