Skip to content

Commit

Permalink
Couple of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tcezard committed Aug 23, 2024
1 parent c964fe4 commit 1b78f2f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion eva_sub_cli/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def orchestrate_process(submission_dir, vcf_files, reference_fasta, metadata_jso

metadata_file = metadata_json or metadata_xlsx
if not os.path.exists(os.path.abspath(metadata_file)):
raise FileNotFoundError(f'The provided metadata file {metadata_file} does not exist')
raise FileNotFoundError(f'The provided metadata file {os.path.abspath(metadata_file)} does not exist')

if metadata_json:
metadata_json = os.path.abspath(metadata_json)
Expand Down
3 changes: 2 additions & 1 deletion eva_sub_cli/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def _upload_submission(self):
def _upload_file(self, submission_upload_url, input_file):
base_name = os.path.basename(input_file)
self.debug(f'Transfer {base_name} to EVA FTP')
r = requests.put(os.path.join(submission_upload_url, base_name), data=open(input_file, 'rb'))
with open(input_file, 'rb') as f:
r = requests.put(os.path.join(submission_upload_url, base_name), data=open(input_file, 'rb'))
r.raise_for_status()
self.debug(f'Upload of {base_name} completed')

Expand Down
2 changes: 1 addition & 1 deletion eva_sub_cli/validators/docker_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
logger = logging_config.get_logger(__name__)

container_image = 'ebivariation/eva-sub-cli'
container_tag = 'v0.0.1.dev14'
container_tag = 'v0.0.1.dev15'
container_validation_dir = '/opt/vcf_validation'
container_validation_output_dir = 'vcf_validation_output'

Expand Down
4 changes: 4 additions & 0 deletions eva_sub_cli/validators/native_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ def _validate(self):

def run_validator(self):
self.verify_executables_installed()
curr_wd = os.getcwd()
try:
command = self.get_validation_cmd()
os.chdir(self.submission_dir)
self._run_quiet_command("Run Validation using Nextflow", command)
except subprocess.CalledProcessError as ex:
logger.error(ex)
finally:
os.chdir(curr_wd)

def get_validation_cmd(self):
if self.metadata_xlsx and not self.metadata_json:
Expand Down
10 changes: 6 additions & 4 deletions tests/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,13 @@ def test_orchestrate_with_metadata_xlsx(self):
)
m_docker_validator().validate_and_report.assert_called_once_with()


def test_metadata_file_does_not_exist_error(self):
with self.assertRaises(Exception) as context:
orchestrate_process(self.test_sub_dir, None, None, None, self.metadata_xlsx,
tasks=[VALIDATE], executor=DOCKER)
self.assertRegex(str(context.exception),r"The provided metadata file .*/resources/test_sub_dir/sub_metadata.xlsx does not exist")
orchestrate_process(self.test_sub_dir, None, None, None, 'Non_existing_metadata.xlsx',
tasks=[VALIDATE], executor=DOCKER)
self.assertRegex(
str(context.exception),
r"The provided metadata file .*/resources/test_sub_dir/Non_existing_metadata.xlsx does not exist"
)


0 comments on commit 1b78f2f

Please sign in to comment.