docs: add torch and tf tensors to Api references section#1345
Conversation
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>
samsja
left a comment
There was a problem hiding this comment.
lgtm, approving so that you can merge when test pass
| 'AudioTorchTensor', | ||
| 'VideoTorchTensor', | ||
| ] | ||
| __all__.extend(_torch_tensors) |
There was a problem hiding this comment.
@samsja The torch tensors were not included in the docstring tests, because they were not found in __alll__. Is it okay to add them to all outside of the following __getattr__? In this case, they are included in all also if torch is not installed.
There was a problem hiding this comment.
best way would be to create a __all_test__ for them or just to write a custom docstring test just for the tensor thing
There was a problem hiding this comment.
in the test, you could do smth like this.
`all_test == hasattr(module, 'all_test') or hasattr(module, 'all')
There was a problem hiding this comment.
how about this:
if "pytest" in sys.modules:
__all__.extend(_torch_tensors)There was a problem hiding this comment.
hmmm not sure. This means
from docarray.typing import *
TorchTensor()has a different behavior inside and outside pytest. It kind of go against the principle of tests. Something could go wrong outside of pytest but not in pytest
There was a problem hiding this comment.
ok, I will go with the __all_test__ option that you suggested!
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>
|
📝 Docs are deployed on https://ft-docs-add-torch-and-tf-tensors--jina-docs.netlify.app 🎉 |
Goals:
Currently all tf and torch tensors do not appear in the
Api referencessection. I think this might be due to the fact that those are not included in the__init__.py's__all__list.For instance in the
docarray.typing.tensor.__init__.pythe tf and torch tensors will be added only via the__get_attr__(). Mkdocstring does not seem to find those.So I think they have to be added explicitly.
My current solution:
Split tensor section into AudioTensor, ImageTensor, Embedding, VideoTensor and Tensor. For each section I'll add the files explicitly:
This however results in a not so great looking table of contents (on the right):

For each file, the filepath is listed, as well as the class inside of it.
Update:
I just realized that that is the same for some of the other sections, so I guess it is fine like this