Skip to content

Commit

Permalink
add phone columnn (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
felix5572 authored Feb 27, 2023
2 parents 0d323a7 + 21c63e9 commit 77930b6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
13 changes: 10 additions & 3 deletions dpdispatcher/dp_cloud_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ 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:
if email is None and phone is None:
raise ValueError(
"can not find email in remote_profile, please check your machine file."
"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."
Expand All @@ -47,7 +49,12 @@ def __init__(self, context):
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):
Expand Down
14 changes: 10 additions & 4 deletions dpdispatcher/dp_cloud_server_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,22 @@ def __init__(
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:
if email is None and phone is None:
raise ValueError(
"can not find email in remote_profile, please check your machine file."
"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)

Expand Down Expand Up @@ -290,7 +296,7 @@ def machine_subfields(cls) -> List[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",
Expand Down

0 comments on commit 77930b6

Please sign in to comment.