Skip to content

Commit

Permalink
solution for #536 and #522
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Dec 23, 2024
1 parent 222abac commit fed3fd3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 32 deletions.
60 changes: 36 additions & 24 deletions looper/looper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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

Expand Down
20 changes: 13 additions & 7 deletions tests/smoketests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_comprehensive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit fed3fd3

Please sign in to comment.