Skip to content

Commit

Permalink
Add check, report, destroy, and table to tests, add returning debug …
Browse files Browse the repository at this point in the history
…values for table #464
  • Loading branch information
donaldcampbelljr committed Feb 26, 2024
1 parent d4cfe23 commit cf74a6d
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
4 changes: 2 additions & 2 deletions looper/cli_looper.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,13 +761,13 @@ def main(test_args=None):
)
if args.command == "table":
if use_pipestat:
Tabulator(prj)(args)
return Tabulator(prj)(args)
else:
raise PipestatConfigurationException("table")

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

Expand Down
6 changes: 5 additions & 1 deletion looper/looper.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ class Reporter(Executor):

def __call__(self, args):
# initialize the report builder
self.debug = {}
p = self.prj
project_level = args.project

Expand All @@ -559,6 +560,8 @@ def __call__(self, args):
looper_samples=self.prj.samples, portable=portable
)
print(f"Report directory: {report_directory}")
self.debug["report_directory"] = report_directory
return self.debug
else:
for piface_source_samples in self.prj._samples_by_piface(
self.prj.piface_key
Expand All @@ -576,6 +579,8 @@ def __call__(self, args):
looper_samples=self.prj.samples, portable=portable
)
print(f"Report directory: {report_directory}")
self.debug["report_directory"] = report_directory
return self.debug


class Linker(Executor):
Expand Down Expand Up @@ -614,7 +619,6 @@ class Tabulator(Executor):
"""

def __call__(self, args):
# p = self.prj
project_level = args.project
results = []
if project_level:
Expand Down
62 changes: 62 additions & 0 deletions tests/test_comprehensive.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from tests.smoketests.test_run import is_connected
from tempfile import TemporaryDirectory
from git import Repo
from pipestat import PipestatManager

from yaml import dump, safe_load

Expand Down Expand Up @@ -68,4 +69,65 @@ def test_comprehensive_looper_pipestat():
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

# TODO TEST PROJECT LEVEL RUN
# Must add this to hello_looper for pipestat example

# TEST LOOPER CHECK

# looper cannot create flags, the pipeline or pipestat does that
# if you do not specify flag dir, pipestat places them in the same dir as config file
path_to_pipestat_config = os.path.join(
pipestat_dir, "looper_pipestat_config.yaml"
)
psm = PipestatManager(config_file=path_to_pipestat_config)
psm.set_status(record_identifier="frog_1", status_identifier="completed")
psm.set_status(record_identifier="frog_2", status_identifier="completed")

# Now use looper check to get statuses
x = ["check", "--looper-config", path_to_looper_config]

try:
result = main(test_args=x)
assert result["example_pipestat_pipeline"]["frog_1"] == "completed"
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

# TEST LOOPER REPORT

x = ["report", "--looper-config", path_to_looper_config]

try:
result = main(test_args=x)
assert "report_directory" in result
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

# TEST LOOPER Table

x = ["table", "--looper-config", path_to_looper_config]

try:
result = main(test_args=x)
assert "example_pipestat_pipeline_stats_summary.tsv" in result[0]
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

# TEST LOOPER DESTROY
# TODO add destroying individual samples via pipestat

x = [
"destroy",
"--looper-config",
path_to_looper_config,
"--force-yes",
] # Must force yes or pytest will throw an exception "OSError: pytest: reading from stdin while output is captured!"

try:
result = main(test_args=x)
# assert "report_directory" in result
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

# TODO TEST LOOPER INSPECT -> I believe this moved to Eido?

print(result)

0 comments on commit cf74a6d

Please sign in to comment.