diff --git a/looper/looper.py b/looper/looper.py index 8a1bac05..a9d45d05 100755 --- a/looper/looper.py +++ b/looper/looper.py @@ -95,11 +95,15 @@ def __call__(self, args): for piface in self.prj.project_pipeline_interfaces: if piface.psm.pipeline_type == PipelineLevel.PROJECT.value: - psms[piface.psm.pipeline_name] = piface.psm - s = piface.psm.get_status() or "unknown" + if piface.psm.pipeline_name not in psms: + psms[piface.psm.pipeline_name] = piface.psm + for pl_name, psm in psms.items(): + all_project_level_records = psm.select_records() + for record in all_project_level_records['records']: + s = piface.psm.get_status(record_identifier=record['record_identifier']) status.setdefault(piface.psm.pipeline_name, {}) - status[piface.psm.pipeline_name][self.prj.name] = s - _LOGGER.debug(f"{self.prj.name} ({piface.psm.pipeline_name}): {s}") + status[piface.psm.pipeline_name][record['record_identifier']] = s + _LOGGER.debug(f"{self.prj.name} ({record['record_identifier']}): {s}") else: for sample in self.prj.samples: @@ -566,28 +570,32 @@ def __call__(self, args): for piface in self.prj.project_pipeline_interfaces: if piface.psm.pipeline_type == PipelineLevel.PROJECT.value: - psms[piface.psm.pipeline_name] = piface.psm - try: - report_directory = piface.psm.summarize( - looper_samples=self.prj.samples, portable=portable - ) - except PipestatSummarizeError as e: - raise LooperReportError(f"Looper report error due to the following exception: {e}") + if piface.psm.pipeline_name not in psms: + psms[piface.psm.pipeline_name] = piface.psm + for pl_name, psm in psms.items(): + try: + report_directory = psm.summarize( + looper_samples=self.prj.samples, portable=portable + ) + except PipestatSummarizeError as e: + raise LooperReportError(f"Looper report error due to the following exception: {e}") print(f"Report directory: {report_directory}") self.debug["report_directory"] = report_directory return self.debug else: for piface in self.prj.pipeline_interfaces: if piface.psm.pipeline_type == PipelineLevel.SAMPLE.value: - psms[piface.psm.pipeline_name] = piface.psm - try: - report_directory = piface.psm.summarize( - looper_samples=self.prj.samples, portable=portable - ) - except PipestatSummarizeError as e: - raise LooperReportError(f"Looper report error due to the following exception: {e}") - print(f"Report directory: {report_directory}") - self.debug["report_directory"] = report_directory + if piface.psm.pipeline_name not in psms: + psms[piface.psm.pipeline_name] = piface.psm + for pl_name, psm in psms.items(): + try: + report_directory = psm.summarize( + looper_samples=self.prj.samples, portable=portable + ) + except PipestatSummarizeError as e: + raise LooperReportError(f"Looper report error due to the following exception: {e}") + print(f"Report directory: {report_directory}") + self.debug["report_directory"] = report_directory return self.debug @@ -630,13 +638,17 @@ def __call__(self, args): if project_level: for piface in self.prj.project_pipeline_interfaces: if piface.psm.pipeline_type == PipelineLevel.PROJECT.value: - psms[piface.psm.pipeline_name] = piface.psm - results = piface.psm.table() + if piface.psm.pipeline_name not in psms: + psms[piface.psm.pipeline_name] = piface.psm + for pl_name, psm in psms.items(): + results = psm.table() else: for piface in self.prj.pipeline_interfaces: if piface.psm.pipeline_type == PipelineLevel.SAMPLE.value: - psms[piface.psm.pipeline_name] = piface.psm - results = piface.psm.table() + if piface.psm.pipeline_name not in psms: + psms[piface.psm.pipeline_name] = piface.psm + for pl_name, psm in psms.items(): + results = psm.table() # Results contains paths to stats and object summaries. return results diff --git a/tests/smoketests/test_other.py b/tests/smoketests/test_other.py index 9713d16a..85f65f3a 100644 --- a/tests/smoketests/test_other.py +++ b/tests/smoketests/test_other.py @@ -3,7 +3,7 @@ import pytest from peppy import Project -from looper.exceptions import PipestatConfigurationException, MisconfigurationException +from looper.exceptions import PipestatConfigurationException, MisconfigurationException, LooperReportError from tests.conftest import * from looper.cli_pydantic import main import pandas as pd @@ -78,12 +78,18 @@ def test_pipestat_configured(self, prep_temp_pep_pipestat, cmd): # Not every command supports dry run x = [cmd, "--config", tp] - try: - result = main(test_args=x) - if cmd == "run": - assert result["Pipestat compatible"] is True - except Exception: - raise pytest.fail("DID RAISE {0}".format(Exception)) + if cmd not in ["report"]: + try: + result = main(test_args=x) + if cmd == "run": + assert result["Pipestat compatible"] is True + except Exception: + raise pytest.fail("DID RAISE {0}".format(Exception)) + else: + with pytest.raises(expected_exception=LooperReportError): # Looper report will and should raise exception if there are no results reported. + result = main(test_args=x) + + class TestLooperRerun: diff --git a/tests/test_comprehensive.py b/tests/test_comprehensive.py index cb79b356..41c73ea0 100644 --- a/tests/test_comprehensive.py +++ b/tests/test_comprehensive.py @@ -123,7 +123,7 @@ def test_comprehensive_looper_pipestat(prep_temp_pep_pipestat): try: result = main(test_args=x) - assert result == {"example_pipestat_pipeline": {"project": "unknown"}} + assert result == {} except Exception: raise pytest.fail("DID RAISE {0}".format(Exception))