Skip to content

Commit

Permalink
refactor: use hubble sdk for get_token (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxiao authored Aug 11, 2022
1 parent f7b8eb8 commit 930c75c
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 183 deletions.
20 changes: 6 additions & 14 deletions docarray/array/mixins/io/pushpull.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ class PushPullMixin:

_max_bytes = 4 * 1024 * 1024 * 1024

@property
def auth_token(self) -> Optional[str]:
import hubble

if 'HUBBLE_HINT_SHOWED' not in os.environ:
token = hubble.show_hint()
os.environ['HUBBLE_HINT_SHOWED'] = '1'
else:
token = hubble.Client(jsonify=True).token

return os.environ.get('JINA_AUTH_TOKEN', token)

def push(
self,
name: str,
Expand Down Expand Up @@ -63,8 +51,9 @@ def push(
)

headers = {'Content-Type': ctype, **get_request_header()}
import hubble

auth_token = self.auth_token
auth_token = hubble.get_token()
if auth_token:
headers['Authorization'] = f'token {auth_token}'

Expand Down Expand Up @@ -144,7 +133,10 @@ def pull(

headers = {}

auth_token = cls.auth_token
import hubble

auth_token = hubble.get_token()

if auth_token:
headers['Authorization'] = f'token {auth_token}'

Expand Down
7 changes: 7 additions & 0 deletions docarray/array/mixins/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def summary(self):
from rich.table import Table
from rich.console import Console
from rich.panel import Panel
import rich.markup

from rich import box

Expand All @@ -43,6 +44,7 @@ def summary(self):

table = Table(box=box.SIMPLE, highlight=True)
table.show_header = False
table.add_row('Type', self.__class__.__name__)
table.add_row('Length', str(len(self)))
is_homo = len(attr_counter) == 1
table.add_row('Homogenous Documents', str(is_homo))
Expand Down Expand Up @@ -77,6 +79,11 @@ def summary(self):
is_multimodal = all(d.is_multimodal for d in self)
table.add_row('Multimodal dataclass', str(is_multimodal))

if getattr(self, '_subindices'):
table.add_row(
'Subindices', rich.markup.escape(str(tuple(self._subindices.keys())))
)

tables.append(Panel(table, title='Documents Summary', expand=False))

all_attrs_names = tuple(sorted(all_attrs_names))
Expand Down
5 changes: 2 additions & 3 deletions docs/advanced/document-store/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
```{toctree}
:hidden:
weaviate
sqlite
qdrant
annlite
qdrant
elasticsearch
subindex
weaviate
extend
benchmark
```
Expand Down
164 changes: 0 additions & 164 deletions docs/advanced/document-store/subindex.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/fundamentals/documentarray/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ visualization
post-external
embedding
matching
subindex
evaluation
```
2 changes: 1 addition & 1 deletion docs/fundamentals/documentarray/matching.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(match-documentarray)=
# Match Nearest Neighbours
# Find Nearest Neighbours

```{important}
Expand Down
Loading

0 comments on commit 930c75c

Please sign in to comment.