Skip to content

futuremice(): Best practices for undoing future::plan() changes #735

Description

@HenrikBengtsson

Hello, in

mice/R/futuremice.R

Lines 146 to 168 in ded22e4

future::plan(future.plan,
workers = n.core
)
# begin future
imps <- furrr::future_map(
n.imp.core,
function(x) {
mice(data = data,
m = x,
printFlag = FALSE,
seed = seed,
...
)},
.options = furrr::furrr_options(
seed = TRUE,
globals = globals,
packages = packages
)
)
# end multisession
future::plan(future::sequential)

you're resetting the future plan to plan(sequential) when done. Note that the user might have another type of plan set for other reasons. Instead, set your custom plan as:

 with(future::plan(future.plan, 
   workers = n.core 
 ), local = TRUE)

and drop the future::plan(future::sequential) call at the end.

This is the recommended approach to undo plan changes, cf. https://future.futureverse.org/articles/future-7-for-package-developers.html#avoid-changing-the-future-backend

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions