-
Notifications
You must be signed in to change notification settings - Fork 76
Description
Prework
- Read and agree to the code of conduct and contributing guidelines.
- If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
- New features take time and effort to create, and they take even more effort to maintain. So if the purpose of the feature is to resolve a struggle you are encountering personally, please consider first posting a "trouble" or "other" issue so we can discuss your use case and search for existing solutions first.
- Format your code according to the tidyverse style guide.
Proposal
Thanks again for targets. As I use it more, I'm liking a lot of its reproducibility and architecture improvements!
The current error message for a malformed list of targets does not point the user directly to the issue. In a more complex real example, I did a simple assignment within the list of targets similar to the code below, and I got an error that didn't exactly tell me what the issue was.
Contents of _targets.R
:
library(targets)
list(
A=1
)
When I ran tar_make()
, I got this error:
Error : Expected a list of target objects but did not find one. Are you missing a target list at the end of your target script file? The target script file (e.g. _targets.R) must end with a list of tar_target() objects. Each element of the target list must be a target object or nested list of target objects.
Error: callr subprocess failed: Expected a list of target objects but did not find one. Are you missing a target list at the end of your target script file? The target script file (e.g. _targets.R) must end with a list of tar_target() objects. Each element of the target list must be a target object or nested list of target objects.
Visit https://books.ropensci.org/targets/debugging.html for debugging advice.
Run `rlang::last_error()` to see where the error occurred.
I think that it would be preferable to show the user a bit more clearly where the issue is and to separate this general error into a couple of different, more specific errors:
- The last item in the script is not a list: "Expected a list of target objects but did not find one. Are you missing a target list at the end of your target script file? The target script file (e.g. _targets.R) must end with a list of tar_target() objects.
The script given, does not end in a list." - The list is not all targets: "Expected a list of target objects but all items in the list were not targets. [...]" Ideally, this would also point the user to exactly where the error is. Something like "The list[[1]][[2]][[3]] is not a target object." (My issue that I had to debug was along these lines, list[[3]][[12]][[2]] was not a list, and it took a while to find.)
And, along the same lines, it would be a bit clearer for the user if the error message were not duplicated with both the "Error : Expected ..." line and "Error: callr subprocess failed" line. But, that may be hard to control.