From 561ec53ece9d32aa8cdb3df8545453a3f9c8a4a2 Mon Sep 17 00:00:00 2001 From: nkumar2 Date: Mon, 9 Oct 2023 15:06:25 +0100 Subject: [PATCH] review comments --- cli/eva_sub_cli.py | 9 +++++---- cli/submit.py | 7 +++++-- tests/test_submit.py | 4 ++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cli/eva_sub_cli.py b/cli/eva_sub_cli.py index 7ec6d76..25632a3 100644 --- a/cli/eva_sub_cli.py +++ b/cli/eva_sub_cli.py @@ -26,13 +26,13 @@ def get_docker_validator(vcf_files_mapping, output_dir, metadata_json, metadata_ if __name__ == "__main__": - argparser = ArgumentParser(description='EVA SUB CLI - to validate and submit a submission') + argparser = ArgumentParser(description='EVA Submission CLI - validate and submit data to EVA') argparser.add_argument('--task', required=True, choices=[VALIDATE, SUBMIT, RESUME], help='Select a task to perform') argparser.add_argument('--submission_dir', required=True, type=str, help='Full path to the directory where all processing will be done and submission info is/will be stored') - argparser.add_argument("--docker_path", help="Full path to the docker installation, " - "not required if docker is available on path", required=False) + argparser.add_argument("--docker_path", required=False, help="Full path to the docker installation, " + "not required if docker is available in the PATH environment variable") argparser.add_argument("--container_name", help="Name of the docker container", required=False) argparser.add_argument("--vcf_files_mapping", required=False, help="csv file with the mappings for vcf files, fasta and assembly report") @@ -54,7 +54,8 @@ def get_docker_validator(vcf_files_mapping, output_dir, metadata_json, metadata_ if args.task == VALIDATE or args.task == SUBMIT: if not args.vcf_files_mapping: - raise Exception(f"Please provide csv file with the mappings of vcf files using --vcf_files_mapping") + raise Exception(f"Please provide a CSV file which provides VCF and corresponding assembly information " + f"(use the --vcf_files_mapping switch)") if not args.metadata_json and not args.metadata_xlsx: raise Exception(f"Please provide the file that describes the project, analysis, samples and files " f"using either --metadata_json or --metadata_xlsx") diff --git a/cli/submit.py b/cli/submit.py index 4fbce7c..36e37bc 100644 --- a/cli/submit.py +++ b/cli/submit.py @@ -28,6 +28,7 @@ def __init__(self, submission_dir, submission_initiate_url=SUBMISSION_INITIATE_U def update_config_with_submission_id_and_upload_url(self, submission_id, upload_url): self.sub_config.set(SUB_CLI_CONFIG_KEY_SUBMISSION_ID, value=submission_id) self.sub_config.set(SUB_CLI_CONFIG_KEY_SUBMISSION_UPLOAD_URL, value=upload_url) + self.sub_config.backup() self.sub_config.write() # TODO @@ -36,7 +37,8 @@ def upload_submission(self, submission_id=None, submission_upload_url=None): raise Exception(f'Cannot resume submission. Config file is empty') if not self.sub_config[READY_FOR_SUBMISSION_TO_EVA]: - raise Exception(f'There are still validation errors that needs to be fixed. Please fix them before uploading') + raise Exception(f'There are still validation errors that needs to be addressed. ' + f'Please review, address and re-validate before uploading.') if not submission_id or not submission_upload_url: submission_id = self.sub_config[SUB_CLI_CONFIG_KEY_SUBMISSION_ID] @@ -51,7 +53,8 @@ def verify_submission_dir(self, submission_dir): def submit(self, submission_dir): if not self.sub_config[READY_FOR_SUBMISSION_TO_EVA]: - raise Exception(f'There are still validation errors that needs to be fixed. Please fix them before submitting.') + raise Exception(f'There are still validation errors that need to be addressed. ' + f'Please review, address and re-validate before submitting.') self.verify_submission_dir(submission_dir) response = requests.post(self.submission_initiate_url, diff --git a/tests/test_submit.py b/tests/test_submit.py index c5421a4..f42b7fe 100644 --- a/tests/test_submit.py +++ b/tests/test_submit.py @@ -59,6 +59,8 @@ def test_submit(self): "submissionId": "mock_submission_id", "uploadUrl": "directory to use for upload", } + + self.submitter.verify_submission_dir(self.test_sub_dir) sub_config = WritableConfig(self.config_file, version='version1.0') sub_config.set(READY_FOR_SUBMISSION_TO_EVA, value=True) sub_config.write() @@ -68,6 +70,8 @@ def test_submit(self): assert os.path.exists(self.test_sub_dir) assert os.path.exists(self.config_file) + # assert backup file is created + assert os.path.exists(f"{self.config_file}.1") with (open(self.config_file, 'r') as f): sub_config_data = yaml.safe_load(f) assert sub_config_data[SUB_CLI_CONFIG_KEY_SUBMISSION_ID] == "mock_submission_id"