Skip to content

Commit

Permalink
Common parse_log() method made default
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cowart committed Dec 2, 2024
1 parent a0ffb81 commit 0b7ce90
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 61 deletions.
1 change: 1 addition & 0 deletions sequence_processing_pipeline/ConvertJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def run(self, callback=None):
logging.info(f'Successful job: {job_info}')

def parse_logs(self):
# overrides Job.parse_logs() w/tailored parse for specific logs.
log_path = join(self.output_path, 'Logs')
errors = join(log_path, 'Errors.log')

Expand Down
17 changes: 0 additions & 17 deletions sequence_processing_pipeline/FastQCJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from functools import partial
from json import dumps
import logging
import glob


class FastQCJob(Job):
Expand Down Expand Up @@ -305,19 +304,3 @@ def _generate_job_script(self):

with open(sh_details_fp, 'w') as f:
f.write('\n'.join(self.commands))

def parse_logs(self):
log_path = join(self.output_path, 'logs')
files = sorted(glob.glob(join(log_path, '*.out')))
msgs = []

for some_file in files:
with open(some_file, 'r') as f:
msgs += [line for line in f.readlines()
# note 'error' is not same
# requirement as found in QCJob.
# ('error:'). This is a very
# generalized filter.
if 'error' in line.lower()]

return [msg.strip() for msg in msgs]
13 changes: 12 additions & 1 deletion sequence_processing_pipeline/Job.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from inspect import stack
import re
from collections import Counter
from glob import glob


# taken from https://jinja.palletsprojects.com/en/3.0.x/api/#jinja2.BaseLoader
Expand Down Expand Up @@ -126,7 +127,17 @@ def run(self):
raise PipelineError("Base class run() method not implemented.")

def parse_logs(self):
raise PipelineError("Base class parse_logs() method not implemented.")
# by default, look for anything to parse in the logs directory.
log_path = join(self.output_path, 'logs')
files = sorted(glob(join(log_path, '*')))
msgs = []

for some_file in files:
with open(some_file, 'r') as f:
msgs += [line for line in f.readlines()
if 'error:' in line.lower()]

return [msg.strip() for msg in msgs]

def _which(self, file_path, modules_to_load=None):
"""
Expand Down
13 changes: 0 additions & 13 deletions sequence_processing_pipeline/NuQCJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,16 +499,3 @@ def _generate_job_script(self, max_bucket_size):
pmls_path=self.pmls_path))

return job_script_path

def parse_logs(self):
log_path = join(self.output_path, 'logs')
# sorted lists give predictable results
files = sorted(glob(join(log_path, '*.out')))
msgs = []

for some_file in files:
with open(some_file, 'r') as f:
msgs += [line for line in f.readlines()
if 'error:' in line.lower()]

return [msg.strip() for msg in msgs]
13 changes: 11 additions & 2 deletions sequence_processing_pipeline/SeqCountsJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from jinja2 import Environment
from os import walk
from json import dumps
from glob import glob


logging.basicConfig(level=logging.DEBUG)
Expand Down Expand Up @@ -101,8 +102,16 @@ def _generate_job_script(self):
return job_script_path

def parse_logs(self):
# TODO
pass
# overrides Job.parse_logs() w/tailored parse for specific logs.
files = sorted(glob(join(self.log_path, '*.err')))
msgs = []

for some_file in files:
with open(some_file, 'r') as f:
msgs += [line for line in f.readlines()
if line.startswith("[E::stk_size]")]

return [msg.strip() for msg in msgs]

def _aggregate_counts(self):
def extract_metadata(fp):
Expand Down
14 changes: 0 additions & 14 deletions sequence_processing_pipeline/TRIntegrateJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from metapool import load_sample_sheet
from os import makedirs
from shutil import copyfile
from glob import glob


logging.basicConfig(level=logging.DEBUG)
Expand Down Expand Up @@ -162,16 +161,3 @@ def _generate_job_script(self):
"output_dir": self.output_path}))

return job_script_path

def parse_logs(self):
log_path = join(self.output_path, 'logs')
# sorted lists give predictable results
files = sorted(glob(join(log_path, '*.out')))
msgs = []

for some_file in files:
with open(some_file, 'r') as f:
msgs += [line for line in f.readlines()
if 'error:' in line.lower()]

return [msg.strip() for msg in msgs]
14 changes: 0 additions & 14 deletions sequence_processing_pipeline/TellReadJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from .Pipeline import Pipeline
from .PipelineError import PipelineError
from metapool import load_sample_sheet
from glob import glob


logging.basicConfig(level=logging.DEBUG)
Expand Down Expand Up @@ -173,16 +172,3 @@ def _generate_job_script(self):
}))

return job_script_path

def parse_logs(self):
log_path = join(self.output_path, 'logs')
# sorted lists give predictable results
files = sorted(glob(join(log_path, '*.out')))
msgs = []

for some_file in files:
with open(some_file, 'r') as f:
msgs += [line for line in f.readlines()
if 'error:' in line.lower()]

return [msg.strip() for msg in msgs]

0 comments on commit 0b7ce90

Please sign in to comment.