-
Notifications
You must be signed in to change notification settings - Fork 17
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
Fetching globals assigned as function arguments fails when run in parallel #36
Comments
Passing |
There a few things going on here. First, using R options within futures is not (yet) support - not even manually. Example: > library(future)
> plan(multisession, workers = 2)
> options(my_option = "yo")
> a <- getOption("my_option")
> a
[1] "yo"
> b %<-% getOption("my_option")
> b
NULL It's on the wishlist (futureverse/future#172). The main problem of supporting that automatically is that some R options are read-only and other are meant only for the local R session, i.e. it's not obvious what options should be exported to the future and not. |
Second, the design pattern where a package PKG provides: FOO <- function(x=MY_GLOBLALS$x, y=MY_GLOBALS$y) x * y where MY_GLOBALS <- list(x=2L, y=5L) should live in the users global environment is a bit unusual. The exteme example of this would be a package providing: foo <- function(x = 1) {
a * x
} where it expects the user to have |
Forgot to say about R options: See also #16 ('options("test"=5) are not global'). It provides a link to futureverse/future#134 (comment) ('R options: options() are not passed down to futures - should they? (document either way)') which gives a few examples on how to manually "export" R options. |
@arunsrinivasan, have you had a chance to digest/think more about my follow-up comments? I'd like to find which of your use cases are already on the future roadmap and which are new. I'd also like to see if there's anything specific to future.apply here - I don't think so - my understanding is that all your needs will have to be taken care of by the core future framework. |
Apologies for the late reply. I agree the design of function argument with default like I'd be happy if globals could work as intended. I agree this has more to do with |
The example shown below should be quite straightforward to follow. The parallel case doesn't seem to be able to find the global var
x_a
.I came across this behaviour while trying to understand the issue in my original scenario, which is slightly different. I've a package say,
PKG
, which has a function say,FOO
as follows:Then, the
sequential
case works fine butmultisession
/ parallel version fails to find 'x' and 'y' defaults when run with the following code:session info:
The text was updated successfully, but these errors were encountered: