From de167c1e2322685a51d0cc992152ab6c106ae518 Mon Sep 17 00:00:00 2001 From: Zhaofeng Miao <522856232@qq.com> Date: Thu, 19 May 2022 15:33:05 +0800 Subject: [PATCH 1/3] feat(hubble): use fixed domain for hubble api Avoid several problems caused by unstable api.jina.ai --- docarray/array/mixins/io/pushpull.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/docarray/array/mixins/io/pushpull.py b/docarray/array/mixins/io/pushpull.py index cb66a65cacc..21f768574ee 100644 --- a/docarray/array/mixins/io/pushpull.py +++ b/docarray/array/mixins/io/pushpull.py @@ -29,27 +29,14 @@ def _get_hub_config() -> Optional[Dict]: @lru_cache() def _get_cloud_api() -> str: - """Get Cloud Api for transmiting data to the cloud. + """Get Cloud Api for transmitting data to the cloud. - :raises RuntimeError: Encounter error when fetching the cloud Api Url. :return: Cloud Api Url """ if 'JINA_HUBBLE_REGISTRY' in os.environ: - u = os.environ['JINA_HUBBLE_REGISTRY'] - else: - try: - req = Request( - 'https://api.jina.ai/hub/hubble.json', - headers={'User-Agent': 'Mozilla/5.0'}, - ) - with urlopen(req) as resp: - u = json.load(resp)['url'] - except Exception as ex: - raise RuntimeError( - f'Can not fetch Cloud API address from {req.full_url}' - ) from ex - - return u + return os.environ['JINA_HUBBLE_REGISTRY'] + + return 'https://api.hubble.jina.ai' class PushPullMixin: From 9b4977e27353529a9643a5558c93cab9769093f0 Mon Sep 17 00:00:00 2001 From: Zhaofeng Miao <522856232@qq.com> Date: Thu, 19 May 2022 16:26:19 +0800 Subject: [PATCH 2/3] fix: address comment Co-authored-by: AlaeddineAbdessalem --- docarray/array/mixins/io/pushpull.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docarray/array/mixins/io/pushpull.py b/docarray/array/mixins/io/pushpull.py index 21f768574ee..9b0a7d7cbaf 100644 --- a/docarray/array/mixins/io/pushpull.py +++ b/docarray/array/mixins/io/pushpull.py @@ -34,9 +34,7 @@ def _get_cloud_api() -> str: :return: Cloud Api Url """ if 'JINA_HUBBLE_REGISTRY' in os.environ: - return os.environ['JINA_HUBBLE_REGISTRY'] - - return 'https://api.hubble.jina.ai' + return os.environ.get('JINA_HUBBLE_REGISTRY', 'https://api.hubble.jina.ai') class PushPullMixin: From 856e5e1ae31ff72e132856ae6b46521b45c6b061 Mon Sep 17 00:00:00 2001 From: Zhaofeng Miao <522856232@qq.com> Date: Thu, 19 May 2022 16:28:54 +0800 Subject: [PATCH 3/3] fix: address comments again --- docarray/array/mixins/io/pushpull.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docarray/array/mixins/io/pushpull.py b/docarray/array/mixins/io/pushpull.py index 9b0a7d7cbaf..80f626b9d0c 100644 --- a/docarray/array/mixins/io/pushpull.py +++ b/docarray/array/mixins/io/pushpull.py @@ -33,7 +33,6 @@ def _get_cloud_api() -> str: :return: Cloud Api Url """ - if 'JINA_HUBBLE_REGISTRY' in os.environ: return os.environ.get('JINA_HUBBLE_REGISTRY', 'https://api.hubble.jina.ai')