From 2a52280ec8c330ab1cf20f213c13865befab8273 Mon Sep 17 00:00:00 2001 From: Han Xiao Date: Mon, 31 Oct 2022 12:04:23 +0100 Subject: [PATCH 1/2] feat: add docarray version to push Signed-off-by: Han Xiao --- docarray/array/mixins/io/pushpull.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/docarray/array/mixins/io/pushpull.py b/docarray/array/mixins/io/pushpull.py index 7577fdf892d..114a9b9c268 100644 --- a/docarray/array/mixins/io/pushpull.py +++ b/docarray/array/mixins/io/pushpull.py @@ -2,8 +2,6 @@ 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 @@ -11,8 +9,12 @@ 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 ( + get_request_header, + __cache_path__, + _get_array_info, + get_full_version, +) if TYPE_CHECKING: # pragma: no cover from docarray.typing import T @@ -188,7 +190,11 @@ 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, ), } @@ -200,11 +206,6 @@ def push( 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 From 23640d918c808a638529a4c88f87cf586baeb842 Mon Sep 17 00:00:00 2001 From: Han Xiao Date: Mon, 31 Oct 2022 12:43:48 +0100 Subject: [PATCH 2/2] feat: add docarray version to push Signed-off-by: Han Xiao --- docarray/array/mixins/io/pushpull.py | 6 +++--- docarray/helper.py | 8 -------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/docarray/array/mixins/io/pushpull.py b/docarray/array/mixins/io/pushpull.py index 114a9b9c268..e266d168984 100644 --- a/docarray/array/mixins/io/pushpull.py +++ b/docarray/array/mixins/io/pushpull.py @@ -10,7 +10,6 @@ from hubble.client.endpoints import EndpointsV2 from docarray.helper import ( - get_request_header, __cache_path__, _get_array_info, get_full_version, @@ -200,7 +199,9 @@ def push( } ) - headers = {'Content-Type': ctype, **get_request_header()} + headers = { + 'Content-Type': ctype, + } auth_token = hubble.get_token() if auth_token: @@ -294,7 +295,6 @@ def pull( with requests.get( url, stream=True, - headers=get_request_header(), ) as r: r.raise_for_status() diff --git a/docarray/helper.py b/docarray/helper.py index 01f09c3c9a1..a564532eb78 100644 --- a/docarray/helper.py +++ b/docarray/helper.py @@ -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.