From ece87cd28f1ed7a12c02d31d9bc148e7a5ba2df7 Mon Sep 17 00:00:00 2001 From: Byron Date: Tue, 21 Feb 2023 18:06:22 +0800 Subject: [PATCH 1/4] add phone columnn --- dpdispatcher/dp_cloud_server.py | 11 ++++++++--- dpdispatcher/dp_cloud_server_context.py | 12 +++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/dpdispatcher/dp_cloud_server.py b/dpdispatcher/dp_cloud_server.py index 360ef8e8..80f0c885 100644 --- a/dpdispatcher/dp_cloud_server.py +++ b/dpdispatcher/dp_cloud_server.py @@ -28,18 +28,23 @@ def __init__(self, context): self.api_version = self.input_data.get('lebesgue_version', 2) self.grouped = self.input_data.get('grouped', False) email = context.remote_profile.get("email", None) + phone = context.remote_profile.get("phone", None) username = context.remote_profile.get('username', None) password = context.remote_profile.get('password', None) if email is None and username is not None: raise DeprecationWarning("username is no longer support in current version, " "please consider use email instead of username.") - if email is None: - raise ValueError("can not find email in remote_profile, please check your machine file.") + if email is None and phone is None: + raise ValueError("can not find email/phone number in remote_profile, please check your machine file.") if password is None: raise ValueError("can not find password in remote_profile, please check your machine file.") if self.api_version == 1: raise DeprecationWarning('api version 1 is deprecated. Use version 2 instead.') - self.api = Client(email, password) + + account = email + if email is None: + account = phone + self.api = Client(account, password) self.group_id = None def gen_script(self, job): diff --git a/dpdispatcher/dp_cloud_server_context.py b/dpdispatcher/dp_cloud_server_context.py index 49d5a81c..94981344 100644 --- a/dpdispatcher/dp_cloud_server_context.py +++ b/dpdispatcher/dp_cloud_server_context.py @@ -42,12 +42,18 @@ def __init__(self, self.temp_local_root = os.path.abspath(local_root) self.remote_profile = remote_profile email = remote_profile.get("email", None) + phone = remote_profile.get("phone", None) password = remote_profile.get('password') - if email is None: - raise ValueError("can not find email in remote_profile, please check your machine file.") + if email is None and phone is None: + raise ValueError("can not find email/phone number in remote_profile, please check your machine file.") if password is None: raise ValueError("can not find password in remote_profile, please check your machine file.") - self.api = Client(email, password) + # account 作为登录账号 + account = email + if email is None: + account = phone + + self.api = Client(account, password) os.makedirs(DP_CLOUD_SERVER_HOME_DIR, exist_ok=True) From 3245af2e98796e4f97fb079c29a56ef6d8591117 Mon Sep 17 00:00:00 2001 From: Byron Date: Wed, 22 Feb 2023 11:35:58 +0800 Subject: [PATCH 2/4] add log --- dpdispatcher/machine.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dpdispatcher/machine.py b/dpdispatcher/machine.py index 46a490f9..a2349c21 100644 --- a/dpdispatcher/machine.py +++ b/dpdispatcher/machine.py @@ -132,7 +132,9 @@ def load_from_dict(cls, machine_dict): raise e # check dict base = cls.arginfo() + print("load_from_json.base", base) machine_dict = base.normalize_value(machine_dict, trim_pattern="_*") + print("load_from_json.machine_dict", machine_dict) base.check_value(machine_dict, strict=False) context = BaseContext.load_from_dict(machine_dict) From b75ec832135ca785b9cf73f26624db1c09d55767 Mon Sep 17 00:00:00 2001 From: Byron Date: Wed, 22 Feb 2023 16:09:29 +0800 Subject: [PATCH 3/4] modify argu optional --- dpdispatcher/dp_cloud_server_context.py | 2 +- dpdispatcher/machine.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/dpdispatcher/dp_cloud_server_context.py b/dpdispatcher/dp_cloud_server_context.py index 94981344..e9bba06e 100644 --- a/dpdispatcher/dp_cloud_server_context.py +++ b/dpdispatcher/dp_cloud_server_context.py @@ -268,7 +268,7 @@ def machine_subfields(cls) -> List[Argument]: """ doc_remote_profile = "The information used to maintain the connection with remote machine." return [Argument("remote_profile", dict, [ - Argument("email", str, optional=False, doc="Email"), + # Argument("email", str, optional=False, doc="Email"), Argument("password", str, optional=False, doc="Password"), Argument("program_id", int, optional=False, alias=['project_id'], doc="Program ID"), Argument("keep_backup", bool, optional=True, doc="keep download and upload zip"), diff --git a/dpdispatcher/machine.py b/dpdispatcher/machine.py index a2349c21..46a490f9 100644 --- a/dpdispatcher/machine.py +++ b/dpdispatcher/machine.py @@ -132,9 +132,7 @@ def load_from_dict(cls, machine_dict): raise e # check dict base = cls.arginfo() - print("load_from_json.base", base) machine_dict = base.normalize_value(machine_dict, trim_pattern="_*") - print("load_from_json.machine_dict", machine_dict) base.check_value(machine_dict, strict=False) context = BaseContext.load_from_dict(machine_dict) From 21c63e9b99827e814ad2098af969d5b98c889762 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Feb 2023 12:47:42 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dpdispatcher/dp_cloud_server.py | 18 ++++++++++++------ dpdispatcher/dp_cloud_server_context.py | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dpdispatcher/dp_cloud_server.py b/dpdispatcher/dp_cloud_server.py index 5f477428..51246733 100644 --- a/dpdispatcher/dp_cloud_server.py +++ b/dpdispatcher/dp_cloud_server.py @@ -29,20 +29,26 @@ def __init__(self, context): self.grouped = self.input_data.get("grouped", False) email = context.remote_profile.get("email", None) phone = context.remote_profile.get("phone", None) - username = context.remote_profile.get('username', None) - password = context.remote_profile.get('password', None) + username = context.remote_profile.get("username", None) + password = context.remote_profile.get("password", None) if email is None and username is not None: - raise DeprecationWarning("username is no longer support in current version, " - "please consider use email instead of username.") + raise DeprecationWarning( + "username is no longer support in current version, " + "please consider use email instead of username." + ) if email is None and phone is None: - raise ValueError("can not find email/phone number in remote_profile, please check your machine file.") + raise ValueError( + "can not find email/phone number in remote_profile, please check your machine file." + ) if password is None: raise ValueError( "can not find password in remote_profile, please check your machine file." ) if self.api_version == 1: - raise DeprecationWarning('api version 1 is deprecated. Use version 2 instead.') + raise DeprecationWarning( + "api version 1 is deprecated. Use version 2 instead." + ) account = email if email is None: diff --git a/dpdispatcher/dp_cloud_server_context.py b/dpdispatcher/dp_cloud_server_context.py index d97da409..4bbe534f 100644 --- a/dpdispatcher/dp_cloud_server_context.py +++ b/dpdispatcher/dp_cloud_server_context.py @@ -44,7 +44,7 @@ def __init__( self.remote_profile = remote_profile email = remote_profile.get("email", None) phone = remote_profile.get("phone", None) - password = remote_profile.get('password') + password = remote_profile.get("password") if email is None and phone is None: raise ValueError( "can not find email/phone number in remote_profile, please check your machine file."