Using the ff package with future.callr #588
-
I would like to pass large datasets that are stored as ff files (which map memory to storage) but I have been encountering an issue with using the future.callr package. I was wondering if there is a way to overcome this issue?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You need to guide the future framework here. It fails to identify ff as a package dependency when doing static code inspection of The solution is to pass library(future)
x <- ff::ff(1:10)
plan(sequential)
y %<-% x[1:3] %packages% "ff"
y
#> [1] 1 2 3
plan(future.callr::callr, workers = 1L)
y %<-% x[1:3] %packages% "ff"
y
#> opening ff /tmp/alice/RtmpBlBVrL/ff/ff5db453b3a726.ff
#> [1] 1 2 3
plan(cluster, workers = 1L)
y %<-% x[1:3] %packages% "ff"
y
#> opening ff /tmp/alice/RtmpBlBVrL/ff/ff5db453b3a726.ff
#> [1] 1 2 3 This is not specific to future.callr, it's true for all parallel workers. For completeness, you should also add this when running sequentially. Again, it's one of the corner cases where the framework fail to be automagic. Maybe one day it'll take care of this too ... |
Beta Was this translation helpful? Give feedback.
-
@imola solved this #588 (reply in thread):
The following example illustrates what's going on under the hood: ## Run this example in the temporary folder
opwd <- setwd(tempdir())
## Create a temporary .Rprofile that produces an error
cat("stop('boom')", file=".Rprofile")
## Use callr to evaluate a function
y <- callr::r(function() 42)
#> Error in get_result(output = out, options) :
#> callr subprocess failed: could not start R, exited with non-zero status, has crashed or was killed which is why we get: ## Use future.callr
library(future.callr)
plan(callr)
f <- future(42)
value(f)
#> Error: callr subprocess failed: could not start R, exited with non-zero status, has crashed or was killed Interestingly, it does not happen with PSOCK workers: cl <- parallel::makePSOCKcluster(1L)
parallel::clusterEvalQ(cl, 42)
#> [[1]]
#> [1] 42
library(future)
plan(multisession)
f <- future(42)
value(f)
#> [1] 42 or batchtools; library(future.batchtools)
plan(batchtools_local)
f <- future(42)
value(f)
#> [1] 42 |
Beta Was this translation helpful? Give feedback.
@imola solved this #588 (reply in thread):
The following example illustrates what's going on under the hood:
which is why we get: