You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems calling future::plan inside do.call does not allow to pass extra parameters to strategy through ...
Here is a minimal reprex considering that you have at least more than 2 cores
## call with workers inside multisession, OKfuture::plan(strategy=future::multisession(workers=2))
future::nbrOfWorkers() # 2## call with workers as extra ... argument of plan, OKfuture::plan(strategy=future::multisession, workers=2)
future::nbrOfWorkers() # 2## call within do.call, not working
do.call(what=future::plan, args=list(strategy=future::multisession, workers=2))
future::nbrOfWorkers() # future::availableCores() instead of 2## call within do.call, produces error (which is OK)
do.call(what=future::plan, args=list(strategy=future::multisession(workers=2)))
Thanks for the tips. I just add it and I can confirm that it solved the issue with worker.
However, I think it's worth reopening here because it generates issues with other extra parameters
do.call(what=future::plan, args=list(strategy= quote(future::multisession), workers=2, lazy=TRUE))
# Error: Detected arguments that must not be set via plan() or tweak(): ‘lazy’
PS: if it can help, in my use case I got error with: ‘envir’, ‘packages’, ‘seed’, ‘lazy’, ‘globals’ lazy and envir are explicitely parameters from future::multisession whereas the others should be passed thanks to ...
This happens with former version of {future} using the quote trick and also the current one just installed with remotes::install_github("HenrikBengtsson/future")
PS: if it can help, in my use case I got error with: ‘envir’, ‘packages’, ‘seed’, ‘lazy’, ‘globals’ lazy and envir are explicitely parameters from future::multisession whereas the others should be passed thanks to ...
That's intentional by design, e.g.
> plan(multisession, workers=2, lazy=TRUE)
Error:Detectedargumentsthatmustnotbesetvia plan() or tweak():'lazy'
None of those arguments must be used by plan(). plan() is controlled by the end-user, and if the end user sets any of those, they will change the behavior of the code that the developer had in mind. So, those arguments may only be passed to future() and alike.
I should say that you are right and what I am trying to achieve is close to what is described in futureverse/progressr#78
However, the documentation of future::plan says that ... (if I understand well) could be used to pass argument to the evaluation function i.e. strategy.
Therefore, as lazy and envir are arguments of future::multisession (alike workers), the reasoning according to the documentation is that they should not induce error when called such a way.
# the folowing works:future::multisession(workers=2, lazy=TRUE, envir= new.env())
# but despite the doc, the folowing produces an error
do.call(what=future::plan, args=list(strategy=future::multisession, workers=2, lazy=TRUE, envir= new.env()))
By extension, the documentation of future::multisession says that ... should allow to pass arguments to future::Future, so extra args passed from future::plan should go to future::multissesion and then future::Future (unless prior matched)
As a consequence, while doable with workers, both functions (future::plan and future::mutisession) are incompatible when called within do.call and with other arguments
Activity
HenrikBengtsson commentedon Aug 28, 2022
Thanks for reporting on this. It's been fixed for the next release. Until then, one can use either of:
do.call(plan, args = list(multisession, workers = 2) would ignore the…
allow to pass strategy extra arguments when declaring future::plan see …
gitdemont commentedon Aug 31, 2022
Thanks for the tips. I just add it and I can confirm that it solved the issue with worker.
However, I think it's worth reopening here because it generates issues with other extra parameters
PS: if it can help, in my use case I got error with: ‘envir’, ‘packages’, ‘seed’, ‘lazy’, ‘globals’
lazyandenvirare explicitely parameters from future::multisession whereas the others should be passed thanks to...This happens with former version of {future} using the quote trick and also the current one just installed with remotes::install_github("HenrikBengtsson/future")
HenrikBengtsson commentedon Aug 31, 2022
That's intentional by design, e.g.
None of those arguments must be used by
plan().plan()is controlled by the end-user, and if the end user sets any of those, they will change the behavior of the code that the developer had in mind. So, those arguments may only be passed tofuture()and alike.gitdemont commentedon Aug 31, 2022
I should say that you are right and what I am trying to achieve is close to what is described in futureverse/progressr#78
However, the documentation of future::plan says that
...(if I understand well) could be used to pass argument to the evaluation function i.e.strategy.Therefore, as
lazyandenvirare arguments of future::multisession (alikeworkers), the reasoning according to the documentation is that they should not induce error when called such a way.By extension, the documentation of future::multisession says that
...should allow to pass arguments to future::Future, so extra args passed from future::plan should go to future::multissesion and then future::Future (unless prior matched)As a consequence, while doable with
workers, both functions (future::plan and future::mutisession) are incompatible when called within do.call and with other arguments