-
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
drake_debug does not work with dynamic targets #1214
Comments
For |
Sorry I did not see that in the docs! I'm just wondering if there's a good method for debugging a specific subtarget. All you know about the subtarget that is giving you trouble is the name as far as I can tell. How do you back out which element of the grouping variable(s) produces that subtarget? |
To be honest, I am not sure, and I have been having the same trouble in a large |
|
Ignore the last 2 comments, I got mixed up. Here is a debugging technique that should help you locate a particular sub-target on a grid of library(drake)
plan <- drake_plan(
nums = 1:2,
result = target(
stopifnot(nums <= 1L),
dynamic = map(nums)
)
)
make(plan)
#> ▶ target nums
#> ▶ dynamic result
#> > subtarget result_0b3474bd
#> > subtarget result_b2a5c9b8
#> x fail result_b2a5c9b8
#> Error: target result_b2a5c9b8 failed.
#> diagnose(result_b2a5c9b8)error$message:
#> nums <= 1L is not TRUE
#> diagnose(result_b2a5c9b8)error$calls:
#> 1. └─base::eval(expr = tidy_expr_8a6af5, envir = config$envir_subtargets)
#> 2. ├─base::local(stopifnot(nums <= 1L))
#> 3. │ └─base::eval.parent(substitute(eval(quote(expr), envir)))
#> 4. │ └─base::eval(expr, p)
#> 5. │ └─base::eval(expr, p)
#> 6. └─base::eval(quote(stopifnot(nums <= 1L)), new.env())
#> 7. └─base::eval(quote(stopifnot(nums <= 1L)), new.env())
#> 8. └─base::stopifnot(nums <= 1L)
config <- drake_config(plan)
sub <- drake:::subtarget_names("result", config)
fld <- failed()
sub
#> [1] "result_0b3474bd" "result_b2a5c9b8"
fld
#> [1] "result" "result_b2a5c9b8"
# Index in the grid
which(sub %in% fld)
#> [1] 2 Created on 2020-03-12 by the reprex package (v0.3.0) |
Great this works - seems worth making a wrapper for this? Like It would return a named vector of indices for |
On second thought, an API function for this niche use case seems kind of heavy handed. In c211885, I added the sub-target name and index to the error metadata of the dynamic sub-target and its parent. library(drake)
plan <- drake_plan(
nums = seq_len(2L),
result = target(
stopifnot(nums < 2L),
dynamic = map(nums)
)
)
make(plan)
#> ▶ target nums
#> ▶ dynamic result
#> > subtarget result_0b3474bd
#> > subtarget result_b2a5c9b8
#> x fail result_b2a5c9b8
#> Error: target result_b2a5c9b8 failed.
#> diagnose(result_b2a5c9b8)error$message:
#> nums < 2L is not TRUE
#> diagnose(result_b2a5c9b8)error$calls:
#> 1. └─base::eval(expr = tidy_expr_8a6af5, envir = config$envir_subtargets)
#> 2. ├─base::local(stopifnot(nums < 2L))
#> 3. │ └─base::eval.parent(substitute(eval(quote(expr), envir)))
#> 4. │ └─base::eval(expr, p)
#> 5. │ └─base::eval(expr, p)
#> 6. └─base::eval(quote(stopifnot(nums < 2L)), new.env())
#> 7. └─base::eval(quote(stopifnot(nums < 2L)), new.env())
#> 8. └─base::stopifnot(nums < 2L)
f <- failed()
f
#> [1] "result" "result_b2a5c9b8"
diagnose(f[1], character_only = TRUE)
#> $error
#> <simpleError in eval(quote(stopifnot(nums < 2L)), new.env()): nums < 2L is not TRUE>
#>
#> $seed
#> [1] 1920294608
#>
#> $subtarget
#> [1] "result_b2a5c9b8"
#>
#> $subtarget_index
#> [1] 2
diagnose(f[2], character_only = TRUE)
#> $error
#> <simpleError in eval(quote(stopifnot(nums < 2L)), new.env()): nums < 2L is not TRUE>
#>
#> $seed
#> [1] 1920294608
#>
#> $subtarget
#> [1] "result_b2a5c9b8"
#>
#> $subtarget_index
#> [1] 2 Created on 2020-03-13 by the reprex package (v0.3.0) |
Prework
drake
's code of conduct.remotes::install_github("ropensci/drake")
) and mention the SHA-1 hash of the Git commit you install.ropensci/drake@36b978e
Description
Trying to use
drake_debug
on a dynamic target seems to not work properly. I have tried both the target itself as well as a subtarget.Reproducible example
Created on 2020-03-12 by the reprex package (v0.3.0)
Session info
Expected result
What should have happened? Please be as specific as possible.
Session info
End the reproducible example with a call to
sessionInfo()
in the same session (e.g.reprex(si = TRUE)
) and include the output.The text was updated successfully, but these errors were encountered: