Skip to content
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

Uninformative error thrown by r_make when plan is not assigned/named "plan" #1334

Closed
6 tasks done
robitalec opened this issue Oct 14, 2020 · 4 comments
Closed
6 tasks done

Comments

@robitalec
Copy link
Member

robitalec commented Oct 14, 2020

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.
  • For any problem you identify, post a minimal reproducible example so the maintainer can troubleshoot. A reproducible example is:
    • Runnable: post enough R code and data so any onlooker can create the error on their own computer.
    • Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
    • Readable: format your code according to the tidyverse style guide.

Description

Found an uninformative error thrown by drake if the plan in plan.R is not assigned to a variable named "plan" or assigned altogether.
This happened by accident just copying over a plan to a new project, and it took me a moment to figure out what was going on.
The same error is thrown if you assign the plan to a variable but not named "plan".

Reproducible example

_drake.R

source("scripts/plan.R")

drake_config(plan)

scripts/plan.R

# Load drake
library(drake)


drake_plan(
  printed = print('test')
)
drake::r_make()
Error in if (nrow(plan) < 1L) { : argument is of length zero
Error: callr subprocess failed: argument is of length zero
Type .Last.error.trace to see where the error occured
.Last.error.trace
 Stack trace:

 Process 99907:
 1. (function (r_args = list())  ...
 2. drake:::r_make(r_args = r_args)
 3. drake:::r_drake(source, drake::make_impl, list(), r_fn, r_args)
 4. base:::do.call(r_fn, r_args)
 5. (function (func, args = list(), libpath = .libPaths(), repos = default_repos(),  ...
 6. callr:::get_result(output = out, options)
 7. throw(newerr, parent = remerr[[2]])

 x callr subprocess failed: argument is of length zero 

 Process 100517:
 19. (function (source, d_fn, d_args)  ...
 20. base:::source(source)
 21. base:::withVisible(eval(ei, envir))
 22. base:::eval(ei, envir)
 23. base:::eval(ei, envir)
 24. drake:::drake_config(plan)
 25. drake:::sanitize_plan(plan, envir = envir)
 26. base:::.handleSimpleError(function (e)  ...
 27. h(simpleError(msg, call))

 x argument is of length zero 
@robitalec robitalec changed the title Uninformative error Uninformative error thrown by r_make when plan is not assigned/named "plan" Oct 14, 2020
@wlandau
Copy link
Member

wlandau commented Oct 14, 2020

The issue is that plan() is a deprecated function in drake and you have not assigned your own object to the symbol plan. It will work if plan.R looks like this:

library(drake)
plan <- drake_plan( # Assign the plan to a variable.
  printed = print('test')
)

@wlandau
Copy link
Member

wlandau commented Oct 14, 2020

The plan need not be called plan.

# plan.R
library(drake)
your_plan <- drake_plan( # Assign the plan to a variable.
  printed = print('test')
)

# _drake.R
source("plan.R")
drake_config(your_plan)

@wlandau
Copy link
Member

wlandau commented Oct 14, 2020

Just improved the error message in the dev version.

@robitalec
Copy link
Member Author

Thanks @wlandau.
The new error message helps point me to double check the drake_plan() assignment, perfect.

Sorry about the confusion for the second note - in haste I swapped the name of the variable to check, but forgot that it is simply whatever the plan is named, passed to drake_config().

Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants