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

Globals specified as a named list not exported with map-reduce APIs for certain backends #515

Closed
HenrikBengtsson opened this issue Jun 15, 2021 · 3 comments
Milestone

Comments

@HenrikBengtsson
Copy link
Owner

HenrikBengtsson commented Jun 15, 2021

Issue

library(future.apply)
plan(sequential)
y <- future_lapply(1, FUN = function(x) a * x, future.globals = list(a = 42))
## Error in ...future.FUN(...future.X_jj, ...) : object 'a' not found

and

library(furrr)
plan(sequential)
y <- future_map(1, function(x) a * x, .options = furrr_options(globals = list(a = 42)))
## Error in ...furrr_fn(...) : object 'a' not found

The above works with other types of backends, e.g. plan(cluster, workers = 1L).

Troubleshooting

It works with plain futures:

f <- future(a, globals = list(a = 42))
value(f)
## [1] 42

Since it affects both future.apply and furrr, my best guess is that this needs to be fixed in the future package.

> sessionInfo()
R version 4.1.0 Patched (2021-05-18 r80320)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

Matrix products: default
BLAS:   /home/hb/software/R-devel/R-4-1-branch/lib/R/lib/libRblas.so
LAPACK: /home/hb/software/R-devel/R-4-1-branch/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] future.apply_1.7.0 future_1.21.0     

loaded via a namespace (and not attached):
[1] compiler_4.1.0         parallelly_1.26.0-9001 tools_4.1.0           
[4] parallel_4.1.0         listenv_0.8.0          codetools_0.2-18      
[7] digest_0.6.27          globals_0.14.0
@HenrikBengtsson
Copy link
Owner Author

HenrikBengtsson commented Jun 16, 2021

I think a reproducible example based on plain sequential futures is:

library(future)
plan(sequential)
f <- future(fcn(), globals = list(a=42, fcn=function() a))
value(f)
## Error in fcn() : object 'a' not found

The same works with, say, plan(cluster, workers = 1).

@HenrikBengtsson
Copy link
Owner Author

This fails also with plan(multicore). ... hmm, starting to get a deja vu feeling about this one.

@HenrikBengtsson
Copy link
Owner Author

hmm, starting to get a deja vu feeling about this one.

Indeed, this is the same problem as in HenrikBengtsson/future.apply#10 from May 2018.

HenrikBengtsson added a commit that referenced this issue Jul 29, 2021
HenrikBengtsson added a commit that referenced this issue Aug 6, 2021
HenrikBengtsson added a commit to HenrikBengtsson/globals that referenced this issue May 6, 2022
HenrikBengtsson added a commit that referenced this issue May 8, 2022
The bug fix in future 1.22.0 that addressed the issue where object
'a' in future(fcn(), globals=list(a=42, fcn=function() a)) would
not be found has been redesigned in a more robust way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant