Skip to content
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

Merged
merged 8 commits into from
Jun 24, 2021
Merged

Rerun errored #483

merged 8 commits into from
Jun 24, 2021

Conversation

chasejohnson3
Copy link
Contributor

Acknowledgment

  • I acknowledge that this contribution will be available under the Apache 2 license.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary

When a workflow or task errors and its result is stored in cache, rerunning the same workflow/task again should rerun all
errored tasks and workflows (as discussed with @satra in #482 )

Checklist

  • All tests passing
  • I have added tests to cover my changes
  • I have updated documentation (if necessary)
  • My code follows the code style of this project
    (we are using black: you can pip install pre-commit,
    run pre-commit install in the pydra directory
    and black will be run automatically with each commit)

@codecov
Copy link

codecov bot commented Jun 22, 2021

Codecov Report

Merging #483 (1917c7b) into master (0b04846) will increase coverage by 0.14%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #483      +/-   ##
==========================================
+ Coverage   82.85%   82.99%   +0.14%     
==========================================
  Files          20       20              
  Lines        4035     4035              
  Branches     1116     1116              
==========================================
+ Hits         3343     3349       +6     
+ Misses        494      491       -3     
+ Partials      198      195       -3     
Flag Coverage Δ
unittests 82.92% <100.00%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pydra/engine/core.py 89.10% <100.00%> (+0.65%) ⬆️
pydra/engine/specs.py 88.24% <0.00%> (+0.47%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b04846...1917c7b. Read the comment docs.

Comment on lines 441 to 443
if result is not None:
return result
if not result.errored:
return result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps change to:

if result is not None and not result.errored:
    return result

both here and in the next patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good fix. It does the same thing and is more concise.


task = pass_odds(name="pass_odds", x=[1, 2, 3, 4, 5], cache_dir=tmpdir).split("x")

task()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, the extra task() should be removed.


with pytest.raises(Exception, match="even error") as exinfo:
task()
print("...")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove print.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the print("...") just to make a distinction in the stdout of running the task the first time versus the second time. print("...") could be removed, but I based the assert statements on stdout, so the assert statements would have to be adjusted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a print is needed, a logger instead of print so that it gets captured better by pytest.


with pytest.raises(Exception) as exinfo:
wf()
print("...")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove print.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the print("...") just to make a distinction in the stdout of running the task the first time versus the second time. print("...") could be removed, but I based the assert statements on stdout, so the assert statements would have to be adjusted.

@chasejohnson3
Copy link
Contributor Author

@satra I implemented most of the recommendations you made for this PR. However, I ran into issues trying to track the output of a logger inside pydra tasks, so I kept the print statements. To attempt to avoid picking up print statements from elsewhere, I count print output only containing a string used in these tests.

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with pytest.raises(Exception) as exinfo:
with pytest.raises(Exception):


with pytest.raises(Exception) as exinfo:
wf()
with pytest.raises(Exception) as exinfo:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with pytest.raises(Exception) as exinfo:
with pytest.raises(Exception):

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# There should have been 5 messages of the form "x%2 = XXX" after calling task() the second time
# There should have been 5 messages of the form "x%2 = XXX" after calling task() the first time

# There should have been 5 messages of the form "x%2 = XXX" after calling task() the second time
# There should have been 2 messages of the form "x%2 = XXX" after calling task() the second time
assert tasks_run == 7

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# There should have been 2 messages with "error" after calling task() the first time
# and 2 another messages after calling the second time


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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with pytest.raises(Exception, match="even error") as exinfo:
with pytest.raises(Exception, match="even error"):


with pytest.raises(Exception, match="even error") as exinfo:
task()
with pytest.raises(Exception, match="even error") as exinfo:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with pytest.raises(Exception, match="even error") as exinfo:
with pytest.raises(Exception, match="even error"):

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# There should have been 5 messages of the form "x%2 = XXX" after calling task() the second time
# There should have been 5 messages of the form "x%2 = XXX" after calling task() the first time

# There should have been 5 messages of the form "x%2 = XXX" after calling task() the second time
# There should have been 2 messages of the form "x%2 = XXX" after calling task() the second time
assert tasks_run == 7

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# There should have been 2 messages with "error" after calling task() the first time
# and 2 another messages after calling the second time

@djarecka
Copy link
Collaborator

@chasejohnson3 - thanks for the PR! I've added just a few suggestions

@chasejohnson3
Copy link
Contributor Author

@djarecka Thanks for the feedback! I addressed your recommendations in the most recent commit.

@djarecka
Copy link
Collaborator

Thanks! I believe it's ready to merge? or are you planning to add anything more?

@chasejohnson3
Copy link
Contributor Author

I am not planning on making any more changes. Go ahead and merge

@djarecka djarecka merged commit 996f5a2 into nipype:master Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants