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

future_lapply(X, FUN = with, a) looks for 'a' in the wrong environment #112

Open
HenrikBengtsson opened this issue May 19, 2023 · 2 comments

Comments

@HenrikBengtsson
Copy link
Collaborator

> X <- list(list(a = 1), list(a = 2))
> y <- lapply(X, FUN = with, a)
> X <- list(list(a = 1), list(a = 2))
> y0 <- lapply(X, FUN = with, a)
> y1 <- future.apply::future_lapply(X, FUN = with, a)
Error: object 'a' not found

Enter a frame number, or 0 to exit   

1: future.apply::future_lapply(X, FUN = with, a)
2: future_xapply(FUN = FUN, nX = nX, chunk_args = X, args = list(...), get_chu
3: getGlobalsAndPackagesXApply(FUN = FUN, args = args, MoreArgs = MoreArgs, en
4: (function () 
{
    replicate(sink.number(), sink(NULL))
    if (interactive()

Selection: 0
@HenrikBengtsson HenrikBengtsson added this to the Next release milestone May 19, 2023
@HenrikBengtsson
Copy link
Collaborator Author

HenrikBengtsson commented May 19, 2023

A lower-level reproducible example:

X <- list(list(a = 1))
future.apply:::future_xapply(nX = length(X), chunk_args = X, FUN = with, a, future.stdout = FALSE, future.seed = FALSE, future.scheduling = 1.0, future.chunk.size = 1L, future.label = "", debug = FALSE)
## Error: object 'a' not found
Enter a frame number, or 0 to exit   

1: future.apply:::future_xapply(nX = length(X), chunk_args = X, FUN = with, a,
2: getGlobalsAndPackagesXApply(FUN = FUN, args = args, MoreArgs = MoreArgs, en
3: (function () 
{
    replicate(sink.number(), sink(NULL))
    if (interactive()

This happens because a is a symbol and future.apply:::getGlobalsAndPackagesXApply() calls:

https://github.com/HenrikBengtsson/future.apply/blob/81bfef5f9e774ef52d374c68ffcd2b4397854f6c/R/globals.R#L4

as the first thing.

@HenrikBengtsson
Copy link
Collaborator Author

This has to do with the globals package and a bit with the future package. I doubt there's anything to be solved in this package.

@HenrikBengtsson HenrikBengtsson removed this from the Next release milestone May 19, 2023
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

1 participant