-
Notifications
You must be signed in to change notification settings - Fork 128
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
Should there be a "suppress" trigger? #529
Comments
I think For my use-case an alternative would be to have a permanent error output, which will suppress recomputation of erroneous nodes. |
Another solution which could solve my problem is a special value, e.g. plan <- drake_plan(
a = rnorm(1),
b = if (a>0) sqrt(a) else NULL,
c = if (is.null(b)) NULL else b+1,
d = if (is.null(c)) NULL else c+1
) Would become: plan <- drake_plan(
a = rnorm(1),
b = if (a>0) sqrt(a) else drake_stop(),
c = b+1,
d = c+1
) On top of that node Also, the workaround with result.or.null <- function(FUN, ...) {
args <- list(...)
if (any(sapply(is.null, args))) NULL else do.call(FUN, args)
}
plan <- drake_plan(
a = rnorm(1),
b = if (a>0) sqrt(a) else NULL,
c = result.or.null(my.func, b),
d = result.or.null(my.func, c),
e = result.or.null(my.func, c, d)
) But this solution is very repetitive and rather limiting. E.g., I cannot use expressions anymore. |
I could picture Another side note for clarity. The
The current convention is:
But it is too late to make the change now. |
So far it seems that the second option is the least ugly one and doesn't seem to hit the performance. There should be also a way for drake to understand not build targets which depend non-existing targets. |
The more I think about it, the more I actually like After some reflection, I am basically convinced that we need a new trigger. At the moment, I think The problem I see with |
Nope, that idea has too much refactoring. A new How about a new
|
cc @kendonB because you originally requested triggers. I think trigger modes as described above would combine the best of several worlds. |
See |
Thanks a lot for implementing this! However, it seems that the new trigger functionality can control if a targets gets rebuilt, but it cannot control if it's built for the first time. plan <- drake_plan(
a = -100,
b = target(
sqrt(a),
trigger=trigger(condition=a>0, mode='blacklist')
),
c = b+1
)
clean(destroy=TRUE)
make(plan) The output:
Is this an expected behavior? It is consistent with the current documentation, however not sure if it solves the use-case from #528. |
I may allow missing targets at some point, but does make things more complicated (both because of 2 recommendations that I think meet your use case:
library(drake)
pkgconfig::set_config("drake::strings_in_dots" = "literals")
fake_plan <- data.frame(target = letters[1:3], command = 1)
make(fake_plan)
#> target a
#> target b
#> target c
plan <- drake_plan(
a = target(-100, trigger = trigger()),
b = sqrt(a),
c = b + 1
)
make(plan, trigger = trigger(condition = a > 0, mode = "blacklist"))
#> target a
#> Used non-default triggers. Some targets may not be up to date. Created on 2018-10-08 by the reprex package (v0.2.1) |
FYI: the new |
trigger(suppress = some_code)
would work liketrigger(condition = ...)
except it would override all the other triggers (exceptcondition
) and avoid the build. The second part of #528 brings up a use case, but I am not sure if it is worth making triggers more complicated. Deserves a couple days of thought.The text was updated successfully, but these errors were encountered: