Skip to content

Commit

Permalink
reduce runp and collator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Aug 15, 2023
1 parent dabcd65 commit a29b7b8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 28 deletions.
13 changes: 9 additions & 4 deletions looper/looper.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ def __call__(self, args, **compute_kwargs):
arguments, recognized by looper
"""
jobs = 0
self.debug = {}
project_pifaces = self.prj.project_pipeline_interface_sources
if not project_pifaces:
raise MisconfigurationException(
Expand Down Expand Up @@ -399,6 +400,8 @@ def __call__(self, args, **compute_kwargs):
jobs += conductor.num_job_submissions
_LOGGER.info("\nLooper finished")
_LOGGER.info("Jobs submitted: {}".format(jobs))
self.debug["Jobs submitted"] = jobs
return self.debug


class Runner(Executor):
Expand Down Expand Up @@ -476,6 +479,9 @@ def __call__(self, args, rerun=False, **compute_kwargs):
validate_sample(self.prj, sample.sample_name, schema_file)
except EidoValidationError as e:
_LOGGER.error(f"Short-circuiting due to validation error: {e}")
self.debug[
"EidoValidationError"
] = f"Short-circuiting due to validation error: {e}"
return False
except RemoteYAMLError:
_LOGGER.warn(
Expand Down Expand Up @@ -1070,14 +1076,13 @@ def main(test_args=None):

if "config_file" in vars(args):
if args.config_file is None:
looper_cfg_path = os.path.relpath(dotfile_path(), start = os.curdir)
looper_cfg_path = os.path.relpath(dotfile_path(), start=os.curdir)
try:
if args.looper_config:
looper_config_dict = read_looper_config_file(args.looper_config)
else:
looper_config_dict = read_looper_dotfile()
_LOGGER.info(f"Using looper config ({looper_cfg_path})."
)
_LOGGER.info(f"Using looper config ({looper_cfg_path}).")

for looper_config_key, looper_config_item in looper_config_dict.items():
setattr(args, looper_config_key, looper_config_item)
Expand All @@ -1095,7 +1100,6 @@ def main(test_args=None):
"looper.databio.org/en/latest/looper-config"
)


args = enrich_args_via_cfg(args, aux_parser, test_args)

# If project pipeline interface defined in the cli, change name to: "pipeline_interface"
Expand Down Expand Up @@ -1178,6 +1182,7 @@ def main(test_args=None):
compute_kwargs = _proc_resources_spec(args)
collate = Collator(prj)
collate(args, **compute_kwargs)
return collate.debug

if args.command == "destroy":
return Destroyer(prj)(args)
Expand Down
56 changes: 32 additions & 24 deletions tests/smoketests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ def test_looper_run_basic(self, prep_temp_pep):

def test_looper_multi_pipeline(self, prep_temp_pep):
tp = prep_temp_pep
stdout, stderr, rc = subp_exec(tp, "run")
print_standard_stream(stderr)
assert "Commands submitted: 6 of 6" in str(stderr)
x = test_args_expansion(tp, "run")
try:
result = main(test_args=x)
assert result["Commands submitted"] == "Commands submitted: 6 of 6"
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

def test_looper_single_pipeline(self, prep_temp_pep):
tp = prep_temp_pep
Expand All @@ -127,7 +130,6 @@ def test_looper_single_pipeline(self, prep_temp_pep):
x = test_args_expansion(tp, "run")
try:
result = main(test_args=x)
print(result)
assert result["Commands submitted"] != "Commands submitted: 6 of 6"
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))
Expand Down Expand Up @@ -160,7 +162,7 @@ def test_looper_cli_pipeline(self, prep_temp_pep):
x = test_args_expansion(tp, "run", ["--pipeline-interfaces", pi_pth])
try:
result = main(test_args=x)
print(result)

assert result["Commands submitted"] != "Commands submitted: 3 of 3"
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))
Expand All @@ -176,7 +178,7 @@ def test_looper_no_pipeline(self, prep_temp_pep):
x = test_args_expansion(tp, "run")
try:
result = main(test_args=x)
print(result)

assert result["Jobs submitted"] == 0
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))
Expand All @@ -193,7 +195,7 @@ def test_looper_pipeline_not_found(self, prep_temp_pep):
x = test_args_expansion(tp, "run")
try:
result = main(test_args=x)
print(result)

assert result["Jobs submitted"] == 0
assert "No pipeline interfaces defined" in result.keys()
except Exception:
Expand All @@ -218,7 +220,7 @@ def test_looper_pipeline_invalid(self, prep_temp_pep):
x = test_args_expansion(tp, "run")
try:
result = main(test_args=x)
print(result)

assert result["Jobs submitted"] == 0
assert "No pipeline interfaces defined" in result.keys()
except Exception:
Expand All @@ -234,7 +236,7 @@ def test_looper_sample_attr_missing(self, prep_temp_pep):
x = test_args_expansion(tp, "run")
try:
result = main(test_args=x)
print(result)

assert result["Jobs submitted"] == 0
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))
Expand All @@ -244,20 +246,20 @@ def test_looper_sample_name_whitespace(self, prep_temp_pep):
"""
Piface is ignored when it does not exist
"""
pepfile = prep_temp_pep
tp = prep_temp_pep
imply_whitespace = [
{
IMPLIED_IF_KEY: {"sample_name": "sample1"},
IMPLIED_THEN_KEY: {"sample_name": "sample whitespace"},
}
]
with mod_yaml_data(pepfile) as config_data:
with mod_yaml_data(tp) as config_data:
config_data[SAMPLE_MODS_KEY][IMPLIED_KEY] = imply_whitespace
stdout, stderr, rc = subp_exec(pepfile, "run")
print_standard_stream(stderr)
assert rc == 0
expected_prefix = "Short-circuiting due to validation error"
assert expected_prefix in str(stderr)
x = test_args_expansion(tp, "run")
with pytest.raises(Exception):
result = main(test_args=x)
expected_prefix = "Short-circuiting due to validation error"
assert expected_prefix in str(result["EidoValidationError"])

def test_looper_toggle(self, prep_temp_pep):
"""
Expand All @@ -269,7 +271,7 @@ def test_looper_toggle(self, prep_temp_pep):
x = test_args_expansion(tp, "run")
try:
result = main(test_args=x)
print(result)

assert result["Jobs submitted"] == 0
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))
Expand Down Expand Up @@ -325,8 +327,12 @@ def test_looper_runp_basic(self, prep_temp_pep):

def test_looper_multi_pipeline(self, prep_temp_pep):
tp = prep_temp_pep
stdout, stderr, rc = subp_exec(tp, "runp")
assert "Jobs submitted: 2" in str(stderr)
x = test_args_expansion(tp, "runp")
try:
result = main(test_args=x)
assert result["Jobs submitted"] == 2
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

def test_looper_single_pipeline(self, prep_temp_pep):
tp = prep_temp_pep
Expand All @@ -335,11 +341,13 @@ def test_looper_single_pipeline(self, prep_temp_pep):
config_data[LOOPER_KEY][CLI_KEY]["runp"][
PIPELINE_INTERFACES_KEY
] = piface_path
stdout, stderr, rc = subp_exec(tp, "runp")
print_standard_stream(stderr)
assert rc == 0
assert "Jobs submitted: 2" not in str(stderr)
assert "Jobs submitted: 1" in str(stderr)
x = test_args_expansion(tp, "runp")
try:
result = main(test_args=x)
assert result["Jobs submitted"] != 2
assert result["Jobs submitted"] == 1
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

@pytest.mark.parametrize("arg", CMD_STRS)
def test_cmd_extra_project(self, prep_temp_pep, arg):
Expand Down

0 comments on commit a29b7b8

Please sign in to comment.