From cd843f5d3ad7eb83bcc5532d3412613baba4a071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 20 Apr 2023 18:12:19 +0200 Subject: [PATCH] =?UTF-8?q?=E2=8C=9B=20fix:=20time=20out=20hub=20push?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 3 ++- src/apis/jina_cloud.py | 13 +++++++++++++ src/options/generate/generator.py | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b8c59f4..46732e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,5 @@ psutil jina jcloud jina-hubble-sdk -langchain \ No newline at end of file +langchain +timeout-decorator \ No newline at end of file diff --git a/src/apis/jina_cloud.py b/src/apis/jina_cloud.py index 020e75e..a3d9c6c 100644 --- a/src/apis/jina_cloud.py +++ b/src/apis/jina_cloud.py @@ -11,6 +11,7 @@ from pathlib import Path import click import hubble import requests +import timeout_decorator from hubble.executor.helper import upload_file, archive_package, get_request_header from jcloud.flow import CloudFlow from jina import Flow @@ -62,6 +63,18 @@ In this case, please cancel this run, rerun your gptdeploy command and login int def push_executor(dir_path): + for i in range(3): + try: + _push_executor(dir_path) + break + except timeout_decorator.timeout_decorator.TimeoutError: + print('timeout error, retrying...') + if i == 2: + raise Exception('timeout error, please try again later') + continue + +@timeout_decorator.timeout(10*60) +def _push_executor(dir_path): dir_path = Path(dir_path) md5_hash = hashlib.md5() diff --git a/src/options/generate/generator.py b/src/options/generate/generator.py index 6b03fb0..85ff40a 100644 --- a/src/options/generate/generator.py +++ b/src/options/generate/generator.py @@ -185,6 +185,7 @@ metas: self.write_config_yml(gateway_name, gateway_path, 'custom_gateway.py') # push the gateway + print('Final step...') hubble_log = push_executor(gateway_path) def debug_microservice(self, path, microservice_name, num_approach, packages):