HenrikBengtsson / doFuture

:rocket: R package: doFuture - Use Foreach to Parallelize via Future Framework
https://doFuture.futureverse.org
84 stars 6 forks source link

WISH: Make registerDoFuture() propagate also via future() / %<-% (as it does with %dopar%) #22

Open HenrikBengtsson opened 6 years ago

HenrikBengtsson commented 6 years ago

It would be useful if registerDoFuture() would propagate also via future() / %<-% (as it currently does with %dopar%). Currently, it doesn't:

library("doFuture")
registerDoFuture()
plan(multisession)

print(getDoParName())
# [1] "doFuture"

# registerDoFuture() propagates through %dopar%
> a <- foreach(i = 1L) %dopar% getDoParName()
> a
[[1]]
[1] "doFuture"

# But not through plain futures
b %<-% getDoParName()
> b
# [1] NULL

The workaround is to manual set it inside these futures:

b %<-% {
  registerDoFuture()
  getDoParName()
}
> b
# [1] "doFuture"

which is not ideal.

See also

The background for this feature is in https://github.com/HenrikBengtsson/doFuture/issues/21

HenrikBengtsson commented 11 months ago

This is only needed when using %dopar%; by definition, this is a non-issue when using %dofuture% .