Closed gitdemont closed 1 year ago
Thanks for reporting on this. It's been fixed for the next release. Until then, one can use either of:
do.call(what = future::plan, args = list(strategy = "future::multisession", workers = 2))
do.call(what = future::plan, args = list(strategy = quote(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
andenvir
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: Detected arguments that must not be set via 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 https://github.com/HenrikBengtsson/progressr/issues/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
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 coressessionInfo()