-
Notifications
You must be signed in to change notification settings - Fork 129
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
Have evaluate_plan handle lists of vectors of indices #187
Comments
That's an excellent point. It's often difficult to know when to break things up into targets and when to combined lots of steps into a single target. You are proposing a happy medium, similar to #77 and #79, but more generalized and with informative names. I want to make this sort of thing easier in For your use case, what about this? library(drake)
library(magrittr)
names <- c("1_4", "5_8", "9_12")
values <- gsub("_", ":", names)
test <- drake_plan(test = run_it(wc__)) %>%
expand_plan(values = names) %>%
evaluate_plan(wildcard = "wc__", values = values, expand = FALSE)
test
## target command
## 1 test_1_4 run_it(1:4)
## 2 test_5_8 run_it(5:8)
## 3 test_9_12 run_it(9:12) Unfortunately, |
Better yet: test <- drake_plan(test = run_it(wc__))
test <- evaluate_plan(test, list(wc__ = drake_strings(1:4, 5:8, 9:12)))
test$target <- gsub(":", "_", test$target)
test
## target command
## 1 test_1_4 run_it(1:4)
## 2 test_5_8 run_it(5:8)
## 3 test_9_12 run_it(9:12) Is that sufficient? We still have that annoying call to |
My current workaround does something similar to your suggestion, but using Is it feasible that evaluate_plan could implement my suggestion in a way that's non-breaking? |
Your second solution is less awkward still :) |
Another question: I presume that having colons in target names causes problems, but that may not be true. Do colons in target names cause problems? |
If you do something like make.names("'report.md'")
## [1] "X.report.md." I am resistant to writing a naive ad-hoc parser of my own. |
I think that a naive ad-hoc parser is the right choice if it outputs a
warning. It seems like it would surely avoid more problems than it would
cause
…On Sat, Jan 6, 2018, 10:50 AM Will Landau ***@***.***> wrote:
If you do something like x <- readd("my:target"), you should not have
problems using x. But if you loadd(list = "my:target"), then you may have
trouble using my:target as a symbol. I thought about using make.names(...,
unique = TRUE) in sanitize_plan()
<https://github.com/wlandau-lilly/drake/blob/bb3734f35fdb7caec709648b12c186a7eca3b63a/R/sanitize.R#L1>
to repair all the target names, but it corrupts single-quoted file targets.
make.names("'report.md'")## [1] "X.report.md."
I am resistant to writing a naive ad-hoc parser of my own.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#187 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFFKkYCnt-HLCv0FURYUf9m-_wYb6_2bks5tHpk3gaJpZM4RU8WF>
.
|
In that case, I will include some of the symbols that are likely to come up in this sort of generative templating. I am not going too far just yet because I'm not very good at anticipating weird regexp edge cases. |
The symbol parser for cleaning up target names is repair_target_names(). And for interpreting lists of numeric vectors, I just coerced |
I would like to be able to expand a command by a list of indices. I'm not sure what the best interface is for this but I'd like to be able to do something like:
The text was updated successfully, but these errors were encountered: