Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nitin-ebi committed Oct 9, 2023
1 parent a595b44 commit 561ec53
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
9 changes: 5 additions & 4 deletions cli/eva_sub_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
7 changes: 5 additions & 2 deletions cli/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"
Expand Down

0 comments on commit 561ec53

Please sign in to comment.