Skip to content

Commit

Permalink
Merge pull request #409 from pepkit/pipestat_polish
Browse files Browse the repository at this point in the history
Pipestat compatibility and move table function to pipestat
  • Loading branch information
donaldcampbelljr committed Aug 25, 2023
2 parents 9c7e20a + 7e1ed55 commit 8703d23
Show file tree
Hide file tree
Showing 16 changed files with 429 additions and 2,704 deletions.
30 changes: 19 additions & 11 deletions looper/cli_looper.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,12 @@ def add_subparser(cmd):
metavar="A",
help="List of amendments to activate",
)
for subparser in [report_subparser, table_subparser, check_subparser]:
for subparser in [
report_subparser,
table_subparser,
check_subparser,
destroy_subparser,
]:
subparser.add_argument(
"--project",
help="Process project-level pipelines",
Expand Down Expand Up @@ -697,29 +702,32 @@ def main(test_args=None):
# with no pipestat reporting would not be compatible with
# commands: table, report and check. Therefore we plan maintain
# the old implementations for a couple of releases.
if hasattr(args, "project"):
use_pipestat = (
prj.pipestat_configured_project
if args.project
else prj.pipestat_configured
)
# if hasattr(args, "project"):
# use_pipestat = (
# prj.pipestat_configured_project
# if args.project
# else prj.pipestat_configured
# )
use_pipestat = (
prj.pipestat_configured_project if args.project else prj.pipestat_configured
)
if args.command == "table":
if use_pipestat:
Tabulator(prj)(args)
else:
TableOld(prj)()
raise PipestatConfigurationException("table")

if args.command == "report":
if use_pipestat:
Reporter(prj)(args)
else:
ReportOld(prj)(args)
raise PipestatConfigurationException("report")

if args.command == "check":
if use_pipestat:
Checker(prj)(args)
return Checker(prj)(args)
else:
CheckerOld(prj)(flags=args.flags)
raise PipestatConfigurationException("check")

if args.command == "clean":
return Cleaner(prj)(args)
Expand Down
13 changes: 9 additions & 4 deletions looper/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,15 @@ def write_script(self, pool, size):
namespaces.update({"sample": sample})
else:
namespaces.update({"samples": self.prj.samples})
pipestat_namespace = self._set_pipestat_namespace(
sample_name=sample.sample_name if sample else None
)
namespaces.update({"pipestat": pipestat_namespace})
if self.prj.pipestat_configured:
pipestat_namespace = self._set_pipestat_namespace(
sample_name=sample.sample_name if sample else None
)
namespaces.update({"pipestat": pipestat_namespace})
else:
# Pipestat isn't configured, simply place empty YAMLConfigManager object instead.
pipestat_namespace = YAMLConfigManager()
namespaces.update({"pipestat": pipestat_namespace})
res_pkg = self.pl_iface.choose_resource_package(
namespaces, size or 0
) # config
Expand Down
3 changes: 2 additions & 1 deletion looper/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _get_apperance_dict(type, templ=APPEARANCE_BY_FLAG):
DEFAULT_PIPESTAT_RESULTS_FILE_ATTR = "pipestat_results_file"
PIPESTAT_NAMESPACE_ATTR_KEY = "namespace_attribute"
PIPESTAT_CONFIG_ATTR_KEY = "config_attribute"
PIPESTAT_RESULTS_FILE_ATTR_KEY = "results_file_attribute"
PIPESTAT_RESULTS_FILE_ATTR_KEY = "results_file_path"

PIPE_ARGS_SECTION = "pipeline_args"
CLI_KEY = "cli"
Expand Down Expand Up @@ -224,6 +224,7 @@ def _get_apperance_dict(type, templ=APPEARANCE_BY_FLAG):
DRY_RUN_KEY,
FILE_CHECKS_KEY,
SAMPLE_PL_ARG,
PIPESTAT_KEY,
]

# resource package TSV-related consts
Expand Down
11 changes: 11 additions & 0 deletions looper/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ def __init__(self, sub_cmd, script):
super(JobSubmissionException, self).__init__(reason)


class PipestatConfigurationException(LooperError):
"""Error type for when command fails due to missing pipestat config"""

def __init__(
self,
sub_cmd,
):
reason = "Pipestat must be configured for command {}".format(sub_cmd)
super(PipestatConfigurationException, self).__init__(reason)


class MissingPipelineConfigurationException(LooperError):
"""A selected pipeline needs configuration data."""

Expand Down

0 comments on commit 8703d23

Please sign in to comment.