ropensci / drake

An R-focused pipeline toolkit for reproducibility and high-performance computing
https://docs.ropensci.org/drake
GNU General Public License v3.0
1.34k stars 128 forks source link

Debugging difficulty with incorrect code #1371

Closed billdenney closed 3 years ago

billdenney commented 3 years ago

Prework

Description

I have a large (for me) plan with about 100 targets. While working on it, I had some subtly invalid code. The code parsed with the R parser, but it was definitely an error on my part. When I tried to run the plan, I got the error below. It took me a bit of time to find the problem because the error didn't give any real hints of where the problem started.

The request is to catch coding errors like this and give a more informative error than "subscript out of bounds".

Reproducible example

library(drake)

foo <- function() {
  # Whoops, that plus sign at the end of the line was not intended
  scale_y_log10() +
    mod <- list()
}

make(drake_plan(bar=foo()))
#> Error in e[[2]]: subscript out of bounds

Created on 2021-07-01 by the reprex package (v2.0.0)

wlandau commented 3 years ago

This error happens during drake's static code analysis to detect dependencies. Error messages are now improved:

foo <- function() scale_y_log10() + mod <- list()
drake::make(drake::drake_plan(bar = foo()))
#> Error: subscript out of bounds
#> Malformed code:
#> scale_y_log10() + mod <- list()
#> 
#> Malformed code:
#> function ()  scale_y_log10() + mod <- list()

Created on 2021-07-02 by the reprex package (v2.0.0)

billdenney commented 3 years ago

Thanks!