diff --git a/src/jina_cloud.py b/src/jina_cloud.py index 6d08e2b..04bbf30 100644 --- a/src/jina_cloud.py +++ b/src/jina_cloud.py @@ -7,26 +7,19 @@ from argparse import Namespace from pathlib import Path import hubble -from hubble import AuthenticationRequiredError from hubble.executor.helper import upload_file, archive_package, get_request_header from jcloud.flow import CloudFlow -from jina import Flow - -from src.utils.common import cmd -@hubble.login_required -def _jina_auth_login(): - pass +def redirect_callback(href): + print(f'You need login to Jina first to use GPTDeploy\nPlease open this link in your browser: {href}') def jina_auth_login(): try: - _jina_auth_login() - except AuthenticationRequiredError: - print('Please login to Jina first, to fully use GPTDeploy') - cmd('jina auth login') - + hubble.Client(jsonify=True).get_user_info(log_error=False) + except hubble.AuthenticationRequiredError: + hubble.login(prompt='login', redirect_callback=redirect_callback) def push_executor(dir_path): diff --git a/src/utils/common.py b/src/utils/common.py deleted file mode 100644 index 8171528..0000000 --- a/src/utils/common.py +++ /dev/null @@ -1,15 +0,0 @@ -import subprocess - - -def cmd(command, std_output=False, wait=True): - if isinstance(command, str): - command = command.split() - if not std_output: - process = subprocess.Popen( - command, stdout=subprocess.PIPE, stderr=subprocess.PIPE - ) - else: - process = subprocess.Popen(command) - if wait: - output, error = process.communicate() - return output, error