Skip to content

Commit

Permalink
have self.debug use consts and clean up structure
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Aug 16, 2023
1 parent c0906e6 commit 699e489
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
7 changes: 7 additions & 0 deletions looper/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
"DEFAULT_CONFIG_FILEPATH",
"DEFAULT_CONFIG_SCHEMA",
"DEFAULT_COMPUTE_RESOURCES_NAME",
"DEBUG_JOBS",
"DEBUG_COMMANDS",
"DEBUG_EIDO_VALIDATION",
]

FLAGS = ["completed", "running", "failed", "waiting", "partial"]
Expand Down Expand Up @@ -111,6 +114,10 @@ def _get_apperance_dict(type, templ=APPEARANCE_BY_FLAG):
ret[flag][key] = ret[flag][key].format(type=type)
return ret

# Debug keys
DEBUG_JOBS = "Jobs submitted"
DEBUG_COMMANDS = "Commands submitted"
DEBUG_EIDO_VALIDATION = "EidoValidationError"

# Compute-related (for divvy)
COMPUTE_SETTINGS_VARNAME = ["DIVCFG"]
Expand Down
8 changes: 4 additions & 4 deletions looper/looper.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ 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
self.debug[DEBUG_JOBS] = jobs
return self.debug


Expand Down Expand Up @@ -480,7 +480,7 @@ def __call__(self, args, rerun=False, **compute_kwargs):
except EidoValidationError as e:
_LOGGER.error(f"Short-circuiting due to validation error: {e}")
self.debug[
"EidoValidationError"
DEBUG_EIDO_VALIDATION
] = f"Short-circuiting due to validation error: {e}"
return False
except RemoteYAMLError:
Expand Down Expand Up @@ -525,7 +525,7 @@ def __call__(self, args, rerun=False, **compute_kwargs):
)
)
_LOGGER.info("Commands submitted: {} of {}".format(cmd_sub_total, max_cmds))
self.debug["Commands submitted"] = "Commands submitted: {} of {}".format(
self.debug[DEBUG_COMMANDS] = "{} of {}".format(
cmd_sub_total, max_cmds
)
if args.dry_run:
Expand All @@ -535,7 +535,7 @@ def __call__(self, args, rerun=False, **compute_kwargs):
f"Dry run. No jobs were actually submitted, but {job_sub_total_if_real} would have been."
)
_LOGGER.info("Jobs submitted: {}".format(job_sub_total))
self.debug["Jobs submitted"] = job_sub_total
self.debug[DEBUG_JOBS] = job_sub_total

# Restructure sample/failure data for display.
samples_by_reason = defaultdict(set)
Expand Down
24 changes: 12 additions & 12 deletions tests/smoketests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_looper_multi_pipeline(self, prep_temp_pep):
x = test_args_expansion(tp, "run")
try:
result = main(test_args=x)
assert result["Commands submitted"] == "Commands submitted: 6 of 6"
assert result[DEBUG_COMMANDS] == "6 of 6"
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

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

Expand Down Expand Up @@ -163,7 +163,7 @@ def test_looper_cli_pipeline(self, prep_temp_pep):
try:
result = main(test_args=x)

assert result["Commands submitted"] != "Commands submitted: 3 of 3"
assert result[DEBUG_COMMANDS] != "3 of 3"
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

Expand All @@ -179,7 +179,7 @@ def test_looper_no_pipeline(self, prep_temp_pep):
try:
result = main(test_args=x)

assert result["Jobs submitted"] == 0
assert result[DEBUG_JOBS] == 0
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

Expand All @@ -196,7 +196,7 @@ def test_looper_pipeline_not_found(self, prep_temp_pep):
try:
result = main(test_args=x)

assert result["Jobs submitted"] == 0
assert result[DEBUG_JOBS] == 0
assert "No pipeline interfaces defined" in result.keys()
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))
Expand All @@ -221,7 +221,7 @@ def test_looper_pipeline_invalid(self, prep_temp_pep):
try:
result = main(test_args=x)

assert result["Jobs submitted"] == 0
assert result[DEBUG_JOBS] == 0
assert "No pipeline interfaces defined" in result.keys()
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))
Expand All @@ -237,7 +237,7 @@ def test_looper_sample_attr_missing(self, prep_temp_pep):
try:
result = main(test_args=x)

assert result["Jobs submitted"] == 0
assert result[DEBUG_JOBS] == 0
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

Expand All @@ -259,7 +259,7 @@ def test_looper_sample_name_whitespace(self, prep_temp_pep):
with pytest.raises(Exception):
result = main(test_args=x)
expected_prefix = "Short-circuiting due to validation error"
assert expected_prefix in str(result["EidoValidationError"])
assert expected_prefix in str(result[DEBUG_EIDO_VALIDATION])

def test_looper_toggle(self, prep_temp_pep):
"""
Expand All @@ -272,7 +272,7 @@ def test_looper_toggle(self, prep_temp_pep):
try:
result = main(test_args=x)

assert result["Jobs submitted"] == 0
assert result[DEBUG_JOBS] == 0
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

Expand Down Expand Up @@ -330,7 +330,7 @@ def test_looper_multi_pipeline(self, prep_temp_pep):
x = test_args_expansion(tp, "runp")
try:
result = main(test_args=x)
assert result["Jobs submitted"] == 2
assert result[DEBUG_JOBS] == 2
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

Expand All @@ -344,8 +344,8 @@ def test_looper_single_pipeline(self, prep_temp_pep):
x = test_args_expansion(tp, "runp")
try:
result = main(test_args=x)
assert result["Jobs submitted"] != 2
assert result["Jobs submitted"] == 1
assert result[DEBUG_JOBS] != 2
assert result[DEBUG_JOBS] == 1
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

Expand Down

0 comments on commit 699e489

Please sign in to comment.