diff --git a/cli/submit.py b/cli/submit.py index c9db026..c93927f 100644 --- a/cli/submit.py +++ b/cli/submit.py @@ -5,19 +5,18 @@ import requests import yaml -from ebi_eva_common_pyutils.logger import logging_config, AppLogger +from ebi_eva_common_pyutils.logger import AppLogger from retry import retry from cli.auth import get_auth -logger = logging_config.get_logger(__name__) SUB_CLI_CONFIG_FILE = ".eva-sub-cli-config.yml" SUB_CLI_CONFIG_KEY_SUBMISSION_ID = "submission_id" SUB_CLI_CONFIG_KEY_SUBMISSION_UPLOAD_URL = "submission_upload_url" SUBMISSION_INITIATE_URL = "http://www.ebi.ac.uk/eva/v1/submission/initiate" -class StudySubmitter: +class StudySubmitter(AppLogger): def __init__(self, vcf_files, metadata_file, submission_initiate_url=SUBMISSION_INITIATE_URL): self.auth = get_auth() self.submission_initiate_url = submission_initiate_url @@ -50,11 +49,13 @@ def upload_submission(self, submission_dir, submission_upload_url=None): self.upload_file(submission_upload_url, f) self.upload_file(submission_upload_url, self.metadata_file) - @retry(tries=5, delay=10, backoff=5, logger=logger) + @retry(tries=5, delay=10, backoff=5) def upload_file(self, submission_upload_url, input_file): base_name = os.path.basename(input_file) + self.info(f'Transfer {base_name} to EVA FTP') r = requests.put(urljoin(submission_upload_url, base_name), data=open(input_file, 'rb')) r.raise_for_status() + self.info(f'Upload of {base_name} completed') def verify_submission_dir(self, submission_dir): if not os.path.exists(submission_dir): @@ -69,6 +70,6 @@ def submit(self, submission_dir): 'Authorization': 'Bearer ' + self.auth.token}) response.raise_for_status() response_json = response.json() - logger.info("Submission ID {} received!!".format(response_json["submissionId"])) + self.info("Submission ID {} received!!".format(response_json["submissionId"])) self.create_submission_config_file(submission_dir, response_json["submissionId"], response_json["uploadUrl"]) self.upload_submission(submission_dir, response_json["uploadUrl"])