-
Notifications
You must be signed in to change notification settings - Fork 3
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
Objects of class "expression"
don't seem to be searched recursively
#77
Comments
It is worth noting that I still think the problem is that library(future.apply)
#> Loading required package: future
library(furrr)
plan(multisession, workers = 2)
x <- 0
y <- parse(text = "x")
y
#> expression(x)
future_map(y, eval)
#> Error in ...furrr_fn(...): object 'x' not found
future_lapply(y, eval)
#> [[1]]
#> [1] 0
# Because future_lapply() does this ahead of time:
# if (!is.vector(X) || is.object(X))
# X <- as.list(X)
# Which gives us the list form that findGlobals() correctly searches:
as.list(y)
#> [[1]]
#> x Created on 2021-10-25 by the reprex package (v2.0.1) |
Hello, Thank you very much for your reply! Unfortunately the solution you suggested does not work in my case. I've tried to formulate a simplified example of the code I am running. It looks like this: library(furrr) plan(multisession, workers = 2) fun <- function(arg) arg + 1 f <- function(x) invoke_map(dic[[x]], 2) map("mod", f) Here are the solutions you suggested (see code below): 1 - Pass the function object as an argument rather than its name as a string: Same result, it works with map but not with future_map. library(future.apply) f <- function(x) invoke_map(eval(parse(text = dic[[x]])), 2) map("mod", f) The original code I am running is much more complicated than the example above, but I believe if there is a solution that makes the example work, then it will work also for my code. |
Hello, Is there a solution in the meantime to work around this problem ? Thanks a lot for your help ! |
It seems like
x
should be identified as a potential global here:Originally reported in futureverse/furrr#209
The text was updated successfully, but these errors were encountered: