FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: add nested access for document array by anna-charlotte · Pull Request #956 · docarray/docarray · GitHub

feat: add nested access for document array - #956

Merged
JoanFM merged 26 commits into
feat-rewrite-v2from
feat-nested-access
Dec 23, 2022
Merged

feat: add nested access for document array#956
JoanFM merged 26 commits into
feat-rewrite-v2from
feat-nested-access

Conversation

anna-charlotte commented Dec 19, 2022
edited
Loading

Copy link
Copy Markdown
Contributor

Signed-off-by: anna-charlotte charlotte.gerhaher@jina.ai

Nested access in V2 is possible by calling the nested attributes you want to access on a DocumentArray, e.g. da.image.title. This does not work for nested DocumentArrays though:

class Author(Document):
    name: str


class Book(Document):
    authors: Optional[DocumentArray[Author]]
    content: str


da = DocumentArray[Book](
    [
        Book(
            authors=DocumentArray[Author]([Author(name='Jenny'), Author(name='Ben')]),
            content=f'hello{i}'
        ) for i in range(10)
    ]
)

authors = da.authors.name  # does not work since da.authors is a list of DocumentArrays and does not have

# instead do this:
authors = da.traverse_flat(access_path='authors.name')  # returns List of strings, with len = 20

traverse_flat takes the access path and returns a list of those attributes, flattened on the first level.
da.traverse_flat(access_path='authors.name') therefore returns a list of 20 strings instead of list of ten lists of 2 names each.

  • add traverse_flat + test
  • check and update documentation, if required. See guide

anna-charlotte added 9 commits December 20, 2022 15:00
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
anna-charlotte added 9 commits December 20, 2022 15:14
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
…ct array

Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
anna-charlotte added 4 commits December 22, 2022 18:00
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Comment thread docarray/array/abstract_array.py Outdated
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Comment thread docarray/array/array.py Outdated
anna-charlotte added 3 commits December 23, 2022 11:42
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
anna-charlotte marked this pull request as ready for review December 23, 2022 10:47

Copy link
Copy Markdown

📝 Docs are deployed on https://ft-feat-nested-access--jina-docs.netlify.app 🎉

JoanFM commented Dec 23, 2022

Copy link
Copy Markdown
Member

In the v1, we decided to hide traverse flat behind the [@] accessors, are we expecting to expose this now?

Copy link
Copy Markdown
Contributor Author

@Joan We haven't made the final decision for this yet. For now, we decided on exposing it, but want to reevaluate this when Sami and Johannes are back.

JoanFM merged commit 6e66c31 into feat-rewrite-v2 Dec 23, 2022
JoanFM deleted the feat-nested-access branch December 23, 2022 11:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Investigate nested access from DocumentArray ("access paths")

2 participants


Back | FazBrowse Home | New Git URL