Skip to content

Commit

Permalink
debug CI: Exception not being caught
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cowart committed Feb 22, 2024
1 parent 6548773 commit 322f043
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion sequence_processing_pipeline/Job.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def submit_job(self, script_path, job_parameters=None,
logging.debug("job scheduler call: %s" % cmd)

if self.force_job_fail:
raise JobFailedError("This job died.")
raise JobFailedError("I AM MESSAGE ONE")

# if system_call does not raise a PipelineError(), then the scheduler
# successfully submitted the job. In this case, it should return
Expand Down
8 changes: 6 additions & 2 deletions sequence_processing_pipeline/NuQCJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,22 @@ def run(self, callback=None):
# job_script_path formerly known as:
# process.multiprep.pangenome.adapter-filter.pe.sbatch

print("SUBMITTING JOB...")
try:
job_info = self.submit_job(job_script_path,
job_parameters=' '.join(job_params),
exec_from=self.log_path,
callback=callback)
except JobFailedError as e:
print("I AM HERE")
# When a job has failed, parse the logs generated by this specific
# job to return a more descriptive message to the user.
info = self.parse_logs()
# prepend just the message component of the Error.
info.insert(0, str(e))
raise JobFailedError('\n'.join(info))
# raise JobFailedError('\n'.join(info))
raise JobFailedError("I AM MESSAGE TWO")
print("IF YOU CAN SEE THIS MESSAGE THEN JobFailedError WAS NOT CAUGHT AS EXPECTED")

job_id = job_info['job_id']
logging.debug(f'NuQCJob {job_id} completed')
Expand Down Expand Up @@ -450,14 +454,14 @@ def _generate_job_script(self):
return job_script_path

def parse_logs(self):
print("PARSE_LOGS() CALLED")
log_path = join(self.output_path, 'Logs')
# sorted lists give predictable results
files = sorted(glob.glob(join(log_path, '*.out')))

msgs = []

for some_file in files:
print("PARSE_LOGS.SOME_FILE: %s" % some_file)
with open(some_file, 'r') as f:
msgs += [line for line in f.readlines()
if 'error' in line.lower()]
Expand Down
17 changes: 4 additions & 13 deletions sequence_processing_pipeline/tests/test_NuQCJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,8 @@ def setUp(self):
"[ERROR] Another Standin Error (ASE)."]
}

self.foobar = []

for log_file in log_files:
fp = join(self.qc_log_path, log_file)
self.foobar.append(fp)

with open(fp, 'w') as f:
lines = log_files[log_file]
Expand Down Expand Up @@ -654,19 +651,13 @@ def test_error_msg_from_logs(self):
exp = ("This job died.\n[ERROR] Another Standin Error (ASE).\n[ERROR]"
" Generic Standin Error (GSE).")

for foo in self.foobar:
print("checking %s..." % foo)
self.assertTrue(exists(foo))
with open(foo, 'r') as f:
lines = f.readlines()
print("\tLINES: %s" % lines)

try:
job.run()
except JobFailedError as e:
print(">>>%s<<<" % str(e))
print(">>>%s<<<" % exp)
self.assertEqual(str(e), exp)
print("JobFailedError CAUGHT: %s" % str(e))
#print(">>>%s<<<" % str(e))
#print(">>>%s<<<" % exp)
#self.assertEqual(str(e), exp)

self.assertTrue(False)

Expand Down

0 comments on commit 322f043

Please sign in to comment.