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

Make triggers less susceptible to false positives #480

Merged
merged 4 commits into from
Jul 24, 2018
Merged

Make triggers less susceptible to false positives #480

merged 4 commits into from
Jul 24, 2018

Conversation

wlandau
Copy link
Member

@wlandau wlandau commented Jul 24, 2018

Summary

cc @AlexAxthelm. In #478, we decided to detect dependencies from triggers: for example,

f <- function(){
  1 + 1
}
g <- function(){
  TRUE
}
plan <- drake_plan(
  x = target(
    command = f(),
    trigger = trigger(condition = g())
  )
)
vis_drake_graph(drake_config(plan))

graph

g() may not be part of the command, but we should at least check and process it before we attempt x. The problem with this approach is that it is oversensitive to changes to g(). Clearly, if we change g() to function(){FALSE}, x should not build. But under #478, it does build because the depend trigger is still activated. And we don't want to use trigger(depend = FALSE) because we still want to react to changes to f().

The solution in this PR is to ignore changes to dependencies that only show up in the triggers. Implementation details:

  • Store a new "ignore_changes" igraph attribute in build_drake_graph() to keep track of these trigger-only dependencies.
  • In dependency_hash() and file_dependency_hash(), exclude everything listed in "ignore_changes".

The implementation admittedly added a little complexity to the code base, and it was not my most elegant work. However, it is consistent with the existing internals and design patterns.

Related GitHub issues and pull requests

Checklist

  • I have read drake's code of conduct, and I agree to follow its rules.
  • I have read the guidelines for contributing.
  • I have listed any substantial changes in the development news.
  • I have added testthat unit tests to tests/testthat to confirm that any new features or functionality work correctly.
  • I have tested this pull request locally with devtools::check()
  • This pull request is ready for review.
  • I think this pull request is ready to merge.

Some code dependencies are detected from commands,
others from triggers. If the dependencies of the trigger
change, the command should not necessarily run.
Ensure deps are ready without overreacting to builds
@codecov-io
Copy link

codecov-io commented Jul 24, 2018

Codecov Report

Merging #480 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #480   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          67     67           
  Lines        5638   5666   +28     
=====================================
+ Hits         5638   5666   +28
Impacted Files Coverage Δ
R/meta.R 100% <100%> (ø) ⬆️
R/config.R 100% <100%> (ø) ⬆️
R/graph.R 100% <100%> (ø) ⬆️
R/deprecate.R 100% <100%> (ø) ⬆️

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 34dbfac...80fdba2. Read the comment docs.

@wlandau wlandau merged commit bb4b6a3 into master Jul 24, 2018
@wlandau wlandau deleted the triggers branch July 24, 2018 20:57
@AlexAxthelm
Copy link
Collaborator

I like it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants