From abe53026a2b8f064605a8ea0fc60c8cdb1fb0a27 Mon Sep 17 00:00:00 2001 From: Luik Date: Thu, 20 Jun 2024 18:42:30 +0200 Subject: [PATCH] fix converter version listing command --- biomero/slurm_client.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/biomero/slurm_client.py b/biomero/slurm_client.py index 72a5f35..d142ce7 100644 --- a/biomero/slurm_client.py +++ b/biomero/slurm_client.py @@ -236,7 +236,7 @@ class SlurmClient(Connection): _DEFAULT_SLURM_GIT_SCRIPT_PATH = "slurm-scripts" _OUT_SEP = "--split--" _VERSION_CMD = "ls -h \"{slurm_images_path}/{image_path}\" | grep -oP '(?<=\-|\_)(v.+|latest)(?=.simg|.sif)'" - _CONVERTER_VERSION_CMD = "ls -h \"{converter_path}\" | grep -oP '(convert_.+)(?=.simg|.sif)' | awk '{n=split($0, a, \"_\"); last=a[n]; sub(\"_\"last\"$\", \"\", $0); print $0, last}'" + _CONVERTER_VERSION_CMD = "ls -h \"{converter_path}\" | grep -oP '(convert_.+)(?=.simg|.sif)' | awk '{{n=split($0, a, \"_\"); last=a[n]; sub(\"_\"last\"$\", \"\", $0); print $0, last}}'" # Note, grep returns exitcode 1 if no match is found! # This will translate into a UnexpectedExit error, so mute that if you # don't care about empty. @@ -498,8 +498,10 @@ def list_available_converter_versions(self) -> Dict: cmd = self._CONVERTER_VERSION_CMD.format( converter_path=self.slurm_converters_path), r = self.run_commands([cmd]) - # split lines further into a k,v dict - result_dict = {line.rsplit(' ', 1)[0]: line.rsplit(' ', 1)[1] for line in r.split('\n')} + result_dict = {} + if r.ok: + # split lines further into a k,v dict + result_dict = {line.rsplit(' ', 1)[0]: line.rsplit(' ', 1)[1] for line in r.stdout.strip().split('\n')} return result_dict def setup_converters(self):