-
Notifications
You must be signed in to change notification settings - Fork 6
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
.noexport argument is ignored #56
Comments
Thanks for reporting. Can you please provide a minimal reproducible example for this that I can work with? |
Sure thing. Consider we have two functions:
foreach_fun <- function() {
foreach::foreach(i = 1:10, .noexport = "data") %dopar% {
data <- letters[1:10]
collapse(data)
}
}
collapse <- function(data) {
data <- paste0(data, collapse = ",")
data
}
registerDoFuture()
plan(future::multisession)
foreach_fun()
plan(sequential) And this works fine. Now, suppose we have a variable in our global environment called # Make a very large data frame, 763 MB in size
# Not used for anything
data <- as.data.frame(matrix(nrow = 1e6, ncol = 200)) If you run
For reasons that are beyond me, doParallel and doSNOWTwo adapters, cl <- parallel::makeCluster(parallel::detectCores())
doParallel::registerDoParallel(cl)
# doSNOW::registerDoSNOW(cl) # also works
foreach_fun <- function() {
foreach::foreach(i = 1:10, .export = "collapse") %dopar% {
data <- letters[1:10]
collapse(data)
}
}
foreach_fun()
doParallel::stopImplicitCluster()
registerDoSEQ()
parallel::stopCluster(cl) Why?My intuition is that |
Thanks again for reporting on this. Indeed, the doFuture adapter completely ignored the remotes::install_github("HenrikBengtsson/doFuture", ref="develop") Now, it turns out there's another problem too unrelated to the doFuture package. The collapse <- function(data) {
data <- paste0(data, collapse = ",")
data
} If you switch to, say, collapse <- function(data) {
data2 <- paste0(data, collapse = ",")
data2
} then |
FYI, globals 0.14.0 on CRAN. Fixes the problem where |
doFuture 0.11.0, which acknowledges argument |
As far as I can see, the
.noexport
argument offoreach::foreach
is ignored bydoFuture
.This issue was brought to my attention when it automatically tried to export a variable called
data
in my global environment to a function which uses a variable calleddata
(but is not the same). While you could technically let it export it without serious consequences, this variable is 700Mb and is thus inefficient. Using the.noexport = "data"
did not have any effect when using thedoFuture
adapter, but does work withdoParallel
anddoSNOW
.I have no clue how to fix it, but in the code of
doFuture
andglobals
I can see.noexport
is taken as an argument but never used elsewhere.The text was updated successfully, but these errors were encountered: