-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rerun errored #483
Rerun errored #483
Changes from 7 commits
15be31e
8db3414
8ed7ce4
05ffb61
bff4b4f
4f63c20
80c9019
1917c7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -1361,3 +1361,42 @@ def fun_error(x): | |||||||
# the error traceback should be a list and should point to a specific line in the function | ||||||||
assert isinstance(error_tb, list) | ||||||||
assert "in fun_error" in error_tb[-2] | ||||||||
|
||||||||
|
||||||||
def test_rerun_errored(tmpdir, capfd): | ||||||||
"""Test rerunning a task containing errors. | ||||||||
Only the errored tasks should be rerun""" | ||||||||
|
||||||||
@mark.task | ||||||||
def pass_odds(x): | ||||||||
if x % 2 == 0: | ||||||||
print(f"x%2 = {x % 2} (error)\n") | ||||||||
raise Exception("even error") | ||||||||
else: | ||||||||
print(f"x%2 = {x % 2}\n") | ||||||||
return x | ||||||||
|
||||||||
task = pass_odds(name="pass_odds", x=[1, 2, 3, 4, 5], cache_dir=tmpdir).split("x") | ||||||||
|
||||||||
with pytest.raises(Exception, match="even error") as exinfo: | ||||||||
task() | ||||||||
with pytest.raises(Exception, match="even error") as exinfo: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
task() | ||||||||
|
||||||||
out, err = capfd.readouterr() | ||||||||
stdout_lines = out.splitlines() | ||||||||
|
||||||||
tasks_run = 0 | ||||||||
errors_found = 0 | ||||||||
|
||||||||
for line in stdout_lines: | ||||||||
if "x%2" in line: | ||||||||
tasks_run += 1 | ||||||||
if "(error)" in line: | ||||||||
errors_found += 1 | ||||||||
|
||||||||
# There should have been 5 messages of the form "x%2 = XXX" after calling task() the second time | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
# There should have been 2 messages of the form "x%2 = XXX" after calling task() the second time | ||||||||
assert tasks_run == 7 | ||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
assert errors_found == 4 |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -3,6 +3,7 @@ | |||||||
import time | ||||||||
import attr | ||||||||
from pathlib import Path | ||||||||
import logging | ||||||||
|
||||||||
from .utils import ( | ||||||||
add2, | ||||||||
|
@@ -4687,3 +4688,44 @@ def one_arg_inner(start_number): | |||||||
|
||||||||
res = test_outer.result() | ||||||||
assert res[0].output.res2 == 23 and res[1].output.res2 == 23 | ||||||||
|
||||||||
|
||||||||
def test_rerun_errored(tmpdir, capfd): | ||||||||
"""Test rerunning a workflow containing errors. | ||||||||
Only the errored tasks and workflow should be rerun""" | ||||||||
|
||||||||
@mark.task | ||||||||
def pass_odds(x): | ||||||||
if x % 2 == 0: | ||||||||
print(f"x%2 = {x % 2} (error)\n") | ||||||||
raise Exception("even error") | ||||||||
else: | ||||||||
print(f"x%2 = {x % 2}\n") | ||||||||
return x | ||||||||
|
||||||||
wf = Workflow(name="wf", input_spec=["x"], cache_dir=tmpdir) | ||||||||
wf.add(pass_odds(name="pass_odds", x=[1, 2, 3, 4, 5]).split("x")) | ||||||||
wf.set_output([("out", wf.pass_odds.lzout.out)]) | ||||||||
|
||||||||
with pytest.raises(Exception) as exinfo: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
wf() | ||||||||
with pytest.raises(Exception) as exinfo: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
wf() | ||||||||
|
||||||||
out, err = capfd.readouterr() | ||||||||
stdout_lines = out.splitlines() | ||||||||
|
||||||||
tasks_run = 0 | ||||||||
errors_found = 0 | ||||||||
|
||||||||
for line in stdout_lines: | ||||||||
if "x%2" in line: | ||||||||
tasks_run += 1 | ||||||||
if "(error)" in line: | ||||||||
errors_found += 1 | ||||||||
|
||||||||
# There should have been 5 messages of the form "x%2 = XXX" after calling task() the second time | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
# There should have been 2 messages of the form "x%2 = XXX" after calling task() the second time | ||||||||
assert tasks_run == 7 | ||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
assert errors_found == 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.