futureverse / futureverse/future
Functions in list not found in future
- Dominant language
- R
- Stars
- 1k
- Forks
- 92
- PR merge metrics
- No merged PRs in 30d
Description
Hi, I've been having a problem when I pass in a named list of functions to a complicated set of nested functions in a relatively complicated future topology. At some point down in the future hierarchy, I iterate over the list of functions, applying them to some data.
However, when I do so, I generally encounter errors telling me that the functions in the list (or functions called *in* functions in the list, but have been defined in the global environment) are not found. Below is a simple demonstration of what I'm talking about:
```r
library(future)
f2 <- function(x) "f2 function"
f1 <- function(x) paste0(f2(x), " ", x)
l <- list("first"=f1, "second"=f2)
plan(multisession)
output %<-% { l[["first"]]("a") }
output
```
I get the error: `Error in paste0(f2(x), " ", x) : could not find function "f2"`. I'd really like to be able to programmatically use functions like this, as I do in other areas of R. If there are no easy fixes to the general problem and this is just a limitation of `future`, is there anything else I can do to get around it?
For example, I might be able to just specify them as globals (and keep passing them down through the hierarchy?), but the problem with that is that it seems that users can either let `future` decide the globals automatically or manually decide *all* globals themselves, which would be infeasible to me. If I can't do anything about the general problem, is there a way of *adding* globals to the automatically determined ones?
Contributor guide
Assessment
This issue has not been assessed yet.