Skip to content

feat: make DocList an actual Python List#1457

Merged
JoanFM merged 17 commits intomainfrom
feat-make-doclist-a-list
Apr 27, 2023
Merged

feat: make DocList an actual Python List#1457
JoanFM merged 17 commits intomainfrom
feat-make-doclist-a-list

Conversation

@JoanFM
Copy link
Copy Markdown
Member

@JoanFM JoanFM commented Apr 26, 2023

This PR needs to make sure that DocList is a List, thus fixing the issue that I cannot call schema of a BaseDoc having nested DocList.

@github-actions github-actions bot added size/s and removed size/xs labels Apr 26, 2023
@JoanFM JoanFM force-pushed the feat-make-doclist-a-list branch 2 times, most recently from f7a713f to 162bc1f Compare April 26, 2023 13:56
Copy link
Copy Markdown
Member

@JohannesMessner JohannesMessner left a comment

Choose a reason for hiding this comment

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

LGTM

@JoanFM JoanFM changed the title feat: try to make DocList and actual Python List feat: try to make DocList an actual Python List Apr 26, 2023
Signed-off-by: Joan Fontanals Martinez <[email protected]>
@JoanFM JoanFM force-pushed the feat-make-doclist-a-list branch from 162bc1f to ba6f5f9 Compare April 26, 2023 14:07
@JoanFM JoanFM requested a review from JohannesMessner April 26, 2023 14:37
@@ -139,7 +142,7 @@ def _del_from_indices(self: T, item: Iterable[int]) -> None:
# each delete
del self._data[ix]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we still have _data ?

Copy link
Copy Markdown
Member

@samsja samsja left a comment

Choose a reason for hiding this comment

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

but here we still have the _data things this looks weird no ?

@jupyterjazz
Copy link
Copy Markdown
Contributor

this line is the problem

if isinstance(docs, List):

after this change, it's always true

we could do this

if not isinstance(docs, DocList) and isinstance(docs, List):

Signed-off-by: Joan Fontanals Martinez <[email protected]>
@JoanFM JoanFM force-pushed the feat-make-doclist-a-list branch from cefa41b to 65b89d5 Compare April 26, 2023 15:41
@JoanFM JoanFM marked this pull request as draft April 26, 2023 16:42
Joan Fontanals Martinez and others added 4 commits April 26, 2023 19:55
return super().__getitem__(item)

@classmethod
def __class_getitem__(cls, item: Union[Type[BaseDoc], TypeVar, str]):
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd rather have this redefined at different inheritance levels

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not sure to understand how it will look like

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I do not quite understand this need? what super has another _class_getitem?

Signed-off-by: samsja <[email protected]>
@JoanFM JoanFM changed the title feat: try to make DocList an actual Python List feat: make DocList an actual Python List Apr 27, 2023
Signed-off-by: samsja <[email protected]>
@github-actions
Copy link
Copy Markdown

📝 Docs are deployed on https://ft-feat-make-doclist-a-list--jina-docs.netlify.app 🎉

@JoanFM JoanFM merged commit b3649b4 into main Apr 27, 2023
@JoanFM JoanFM deleted the feat-make-doclist-a-list branch April 27, 2023 09:44
Copy link
Copy Markdown
Contributor

@jupyterjazz jupyterjazz left a comment

Choose a reason for hiding this comment

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

Nice! I'll try out fastapi integration now

Comment on lines +191 to +197
"""Return all v @classmethod
def __class_getitem__(cls, item: Union[Type[BaseDoc], TypeVar, str]):alues of the fields from all docs this doc_list contains
@classmethod
def __class_getitem__(cls, item: Union[Type[BaseDoc], TypeVar, str]):
:param field: name of the fields to extract
:return: Returns a list of the field value for each document
in the doc_list like container
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

note for myself to correct this docstring in my fastapi PR

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.

4 participants