Skip to content

Commit

Permalink
potential fix for #463
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Mar 13, 2024
1 parent 209919c commit 20e94f6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 4 additions & 1 deletion looper/cli_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,17 @@ def run_looper(args: TopLevelParser, parser: ArgumentParser, test_args=None):
exclusion_flag=subcommand_args.exc_flag,
) as prj:
if subcommand_name in ["run", "rerun"]:
rerun = False
if subcommand_name == "rerun":
rerun = True
run = Runner(prj)
try:
# compute_kwargs = _proc_resources_spec(args)
compute_kwargs = _proc_resources_spec(subcommand_args)

# TODO Shouldn't top level args and subcommand args be accessible on the same object?
return run(
subcommand_args, top_level_args=args, rerun=False, **compute_kwargs
subcommand_args, top_level_args=args, rerun=rerun, **compute_kwargs
)
except SampleFailedException:
sys.exit(1)
Expand Down
5 changes: 3 additions & 2 deletions looper/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def add_sample(self, sample, rerun=False):
if sample_statuses:
status_str = ", ".join(sample_statuses)
failed_flag = any("failed" in x for x in sample_statuses)
waiting_flag = any("waiting" in x for x in sample_statuses)
if self.ignore_flags:
msg = f"> Found existing status: {status_str}. Ignoring."
else: # this pipeline already has a status
Expand All @@ -318,11 +319,11 @@ def add_sample(self, sample, rerun=False):
use_this_sample = False
if rerun:
# Rescue the sample if rerun requested, and failed flag is found
if failed_flag:
if failed_flag or waiting_flag:
msg = f"> Re-running failed sample. Status: {status_str}"
use_this_sample = True
else:
msg = f"> Skipping sample because rerun requested, but no failed flag found. Status: {status_str}"
msg = f"> Skipping sample because rerun requested, but no failed or waiting flag found. Status: {status_str}"
use_this_sample = False
if msg:
_LOGGER.info(msg)
Expand Down
15 changes: 15 additions & 0 deletions tests/smoketests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ def test_pipestat_configured(self, prep_temp_pep_pipestat, cmd):
raise pytest.fail("DID RAISE {0}".format(Exception))


class TestLooperRerun:
@pytest.mark.parametrize("flag_id", FLAGS)
@pytest.mark.parametrize("pipeline_name", ["example_pipestat_pipeline"])
def test_pipestat_rerun(self, prep_temp_pep_pipestat, flag_id, pipeline_name):
"""Verify that checking works when multiple flags are created"""
tp = prep_temp_pep_pipestat
_make_flags(tp, FLAGS[2], pipeline_name)

x = ["rerun", "--looper-config", tp]
try:
result = main(test_args=x)
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))


class TestLooperCheck:
@pytest.mark.parametrize("flag_id", FLAGS)
@pytest.mark.parametrize(
Expand Down

0 comments on commit 20e94f6

Please sign in to comment.