-
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
Handle S3 #959
Comments
Now implemented. This does change the dependency structure of some workflows, but not many. It only affects people who define their own S3 generics. How it worksIf the generic do_stuff <- function(x, ...) {
UseMethod("stuff")
}
stuff.class1 <- function(x, ...) {
sqrt(x)
}
stuff.class2 <- function(x, ...) {
x ^ 2
}
library(drake)
plan <- drake_plan(x = do_stuff(make_stuff()))
config <- drake_config(plan)
vis_drake_graph(config) Created on 2019-07-28 by the reprex package (v0.3.0) So in terms of triggering rebuilds in a do_stuff <- function(x, ...) {
if (inherits(x, "class1")) {
sqrt(x)
} else if (inherits(x, "class2")) {
x ^ 2
} else {
stop(
"no applicable method for 'do_stuff' ",
"applied to an object of class ",
class(x)
)
}
} The solution is not perfect. The |
Prework
drake
's code of conduct.Description
S3 methods should be dependencies of their respective generics. We can enforce this in
analyze_function()
.drake/R/analyze_code.R
Lines 173 to 182 in b551da2
If we detect
UseMethod()
in the function, we just need to find all the matching S3 methods inallowed_globals
.The text was updated successfully, but these errors were encountered: