From 906b172c9a224fdabeb182f65a3d3c4689394790 Mon Sep 17 00:00:00 2001 From: Sam Ireland Date: Tue, 14 Nov 2023 14:14:45 +0000 Subject: [PATCH] Handle missing exit codes in process executions --- nextflow/log.py | 6 ++++-- tests/unit/test_log.py | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/nextflow/log.py b/nextflow/log.py index eff1e24..25a7738 100644 --- a/nextflow/log.py +++ b/nextflow/log.py @@ -110,6 +110,8 @@ def get_process_status_from_log(log, process_id): escaped_id = process_id.replace('/', '\\/') match = re.search( - f".+Task completed.+status: ([A-Z]+).+exit: (\d+).+{escaped_id}", log + f".+Task completed.+status: ([A-Z]+).+exit: (.+?);.+{escaped_id}", log ) - return ("FAILED" if match[2] != "0" else match[1]) if match else "-" \ No newline at end of file + if not match: return "-" + if match[2].isdigit() and match[2] != "0": return "FAILED" + return match[1] \ No newline at end of file diff --git a/tests/unit/test_log.py b/tests/unit/test_log.py index 2536387..98addff 100644 --- a/tests/unit/test_log.py +++ b/tests/unit/test_log.py @@ -156,6 +156,7 @@ def setUp(self): "Jun-01 16:46:00.365 [Task monitor] DEBUG n.processor.TaskPollingMonitor - Task completed > TaskHandler[id: 1; name: DEMULTIPLEX:CSV_TO_BARCODE (file.csv); status: COMPLETED; exit: 0; error: -; workDir: /work/d6/31d530a65ef23d1cb302940a782909]\n" "Jun-01 16:46:08.878 [Task monitor] DEBUG n.processor.TaskPollingMonitor - Task completed > TaskHandler[id: 2; name: DEMULTIPLEX:ULTRAPLEX (file.fastq); status: COMPLETED; exit: 0; error: -; workDir: /work/8a/c2a4dc996d54cad136abeb4e4e309a]\n" "Jun-01 16:46:08.878 [Task monitor] DEBUG n.processor.TaskPollingMonitor - Task completed > TaskHandler[id: 2; name: DEMULTIPLEX:ULTRAPLEX (file2.fastq); status: COMPLETED; exit: 1; error: -; workDir: /work/4b/302940a782909c996d54cad31d53d45]\n" + "Nov-14 14:09:42.634 [Task monitor] DEBUG n.processor.TaskPollingMonitor - Task completed > TaskHandler[id: 20; name: NFCORE_FETCHNGS:SRA:SRA_TO_SAMPLESHEET (ERX1234253_ERR1160846); status: COMPLETED; exit: -; error: -; workDir: /Users/sam/Dropbox/Code/flow-api/local/executions/123951903246975190/work/c8/dfda38334147580b403fbf9da01d25]\n" "Jun-01 16:46:13.434 [main] DEBUG nextflow.script.ScriptRunner - > Execution complete -- Goodbye" ) @@ -172,6 +173,12 @@ def test_can_get_fail_process_status_from_log(self): ) + def test_can_handle_missing_exit_code(self): + self.assertEqual( + get_process_status_from_log(self.log, "c8/dfda38"), "COMPLETED" + ) + + def test_can_get_no_process_status_from_log(self): self.assertEqual( get_process_status_from_log(self.log, "1a/c2a4dc"), "-"