Skip to content

Commit

Permalink
Handle missing exit codes in process executions
Browse files Browse the repository at this point in the history
  • Loading branch information
samirelanduk committed Nov 14, 2023
1 parent 23703d2 commit 906b172
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nextflow/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "-"
if not match: return "-"
if match[2].isdigit() and match[2] != "0": return "FAILED"
return match[1]
7 changes: 7 additions & 0 deletions tests/unit/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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"), "-"
Expand Down

0 comments on commit 906b172

Please sign in to comment.