I have an R package and I want to use future
to run stuff asynchronously. future
is not able to find the functions in my package. This is a known issue in the context of golem
apps. I know there is a work-around that involves assigning the functions to the environment in future (see the linked issue), but I'm hoping someone can help me with a function or improvement that will help future
find all functions in my package.
Here's a simplified test package illustrating the problem:
My package testpkg
has this file structure:
testpkg/
├── DESCRIPTION
├── NAMESPACE
├── R
│ └── do_stuff.R
├── man
│ └── do_stuff.Rd
└── testpkg.Rproj
do_stuff.R
is defined as follows:
#' A function that clearly does stuff
#' @export
do_stuff <- function() {
Sys.sleep(1)
"Done"
}
Now in an interactive script I try the following:
devtools::load_all()
library(future)
plan(multisession)
val %<-% do_stuff()
val
And the console reads Error: there is no package called ‘testpkg’
Like I said, I know there are workarounds, but in my actual use case I have many functions some of which depend on other custom functions, so it becomes very loopy to assign each and every one of those functions (not to mention data objects). I'd like a way for future
to see all functions in my package.