Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions docarray/array/mixins/io/pushpull.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
import os
import os.path
import warnings
from collections import Counter
from http import HTTPStatus
from pathlib import Path
from typing import Dict, Type, TYPE_CHECKING, List, Optional, Any

import hubble
from hubble import Client as HubbleClient
from hubble.client.endpoints import EndpointsV2


from docarray.helper import get_request_header, __cache_path__, _get_array_info
from docarray.helper import (
__cache_path__,
_get_array_info,
get_full_version,
)

if TYPE_CHECKING: # pragma: no cover
from docarray.typing import T
Expand Down Expand Up @@ -188,23 +189,24 @@ def push(
'type': 'documentArray',
'public': public,
'metaData': json.dumps(
{'summary': self._get_raw_summary(), 'branding': branding},
{
'summary': self._get_raw_summary(),
'branding': branding,
'version': get_full_version(),
},
sort_keys=True,
),
}
)

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

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

if not public and not auth_token:
warnings.warn(
'You are not logged in, and `public=False` if only for logged in users. To login, use `jina auth login`.'
)

_head, _tail = data.split(delimiter)
_head += self._stream_header
from rich import filesize
Expand Down Expand Up @@ -293,7 +295,6 @@ def pull(
with requests.get(
url,
stream=True,
headers=get_request_header(),
) as r:
r.raise_for_status()

Expand Down
8 changes: 0 additions & 8 deletions docarray/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,6 @@ def download_mermaid_url(mermaid_url, output) -> None:
raise RuntimeError('Invalid or too-complicated graph')


def get_request_header() -> Dict:
"""Return the header of request.

:return: request header
"""
return {k: str(v) for k, v in get_full_version().items()}


def get_full_version() -> Dict:
"""
Get the version of libraries used in Jina and environment variables.
Expand Down