Skip to content

Commit

Permalink
Implement in submission function
Browse files Browse the repository at this point in the history
  • Loading branch information
kdp-cloud committed Nov 21, 2024
1 parent 3313b52 commit 21a481c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
12 changes: 9 additions & 3 deletions mars-cli/mars_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,22 @@ def cli(ctx, development):

@cli.command()
@click.option(
"--webin-username", type=click.STRING, help="Username for webin authentication"
"--webin-username",
type=click.STRING,
help="Username for webin authentication",
envvar="WEBIN_USERNAME",
)
@click.option(
"--metabolights-username",
type=click.STRING,
help="Username for MetaboLights metadata submission",
envvar="METABOLIGHTS_USERNAME",
)
@click.option(
"--metabolights-ftp-username",
type=click.STRING,
help="Username for MetaboLights data submission",
envvar="METABOLIGHTS_FTP_USERNAME",
)
@click.option(
"--credentials-file",
Expand Down Expand Up @@ -288,8 +293,9 @@ def submit(
data_file_paths = [f.name for f in data_files] if file_transfer else []

submission(
credential_service_name,
username_credentials,
webin_username,
metabolights_username,
metabolights_ftp_username,
credentials_file,
isa_json_file.name,
target_repositories,
Expand Down
21 changes: 15 additions & 6 deletions mars-cli/mars_lib/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
get_metabolights_auth_token,
get_webin_auth_token,
load_credentials,
AuthProvider,
)
from mars_lib.biosamples_external_references import (
get_header,
Expand Down Expand Up @@ -48,8 +49,9 @@ def save_step_to_file(time_stamp: float, filename: str, isa_json: IsaJson):


def submission(
credential_service_name: str,
username_credentials: str,
webin_username: str,
metabolights_username: str,
metabolights_ftp_username: str,
credentials_file: TextIOWrapper,
isa_json_file: str,
target_repositories: list[str],
Expand All @@ -63,11 +65,18 @@ def submission(
# Get password from the credential manager
# Else:
# read credentials from file
if not (credential_service_name is None or username_credentials is None):
cm = CredentialManager(credential_service_name)
if all([webin_username, metabolights_username, metabolights_ftp_username]):
user_credentials = {
"username": username_credentials,
"password": cm.get_password_keyring(username_credentials),
cred_pair[0]: {
"username": cred_pair[1],
"password": CredentialManager(cred_pair[0]).get_password_keyring(
cred_pair[1]
),
}
for cred_pair in zip(
AuthProvider.available_providers(),
[webin_username, metabolights_username, metabolights_ftp_username],
)
}
else:
if credentials_file == "":
Expand Down

0 comments on commit 21a481c

Please sign in to comment.