Skip to content

Commit

Permalink
DEPRECATION: Deprecated plan(multiprocess, ...) now equals plan(seque…
Browse files Browse the repository at this point in the history
…ntial); same for multiprocess() -> sequential() [#546]
  • Loading branch information
HenrikBengtsson committed Jan 17, 2023
1 parent e15ebd4 commit 9b632d8
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 127 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: future
Version: 1.30.0-9016
Version: 1.30.0-9017
Title: Unified Parallel and Distributed Processing in R for Everyone
Imports:
digest,
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

* Remove defunct functions `transparent()` and `TransparentFuture()`.

* Deprecated `plan(multiprocess, ...)` now equals `plan(sequential)`,
while still producing one warning each time a future is created.


# Version 1.30.0 [2022-12-15]

Expand Down
37 changes: 9 additions & 28 deletions R/multiprocess.R
Original file line number Diff line number Diff line change
@@ -1,49 +1,30 @@
#' Create a multiprocess future whose value will be resolved asynchronously using multicore or a multisession evaluation
#'
#' A multiprocess future is a future that uses [multicore] evaluation
#' if supported, otherwise it uses [multisession] evaluation.
#' Regardless, its _value is computed and resolved in
#' parallel in another process_.\cr
#' \cr
#' **WARNING: The 'multiprocess' future plan is deprecated.
#' Instead, explicitly specify 'multisession' or 'multicore'. The former works
#' everywhere and is the recommended one between the two. _Forked processing_,
#' which 'multicore' uses, is unstable in various environment and setups.
#' The 'multiprocess' alias is therefore being phased out.**
#' The 'multiprocess' alias is therefore being phased out, and is now
#' equal to using 'sequential' (sic!)**
#'
#' @inheritParams ClusterFuture-class
#' @inheritParams future
#' @inheritParams Future-class
#'
#' @param workers A positive numeric scalar or a function specifying the
#' maximum number of parallel futures that can be active at the same time
#' before blocking.
#' If a function, it is called without arguments _when the future
#' is created_ and its value is used to configure the workers.
#' The function should return a numeric scalar.
#' @param workers Ignored in **future** (>= 1.31.0).
#'
#' @param \dots Additional arguments passed to [Future()].
#'
#' @return
#' A [MultiprocessFuture] implemented as either a
#' [MulticoreFuture] or a [MultisessionFuture].
#'
#' @example incl/multiprocess.R
#'
#' @seealso
#' Internally [multicore()] and [multisession()]
#' are used.
#' A [SequentialFuture] (sic!) since **future** 1.31.0.
#'
#' @keywords internal
#'
#' @export
multiprocess <- function(..., workers = availableCores(), envir = parent.frame()) {
if (!is.element("multiprocess", getOption("future.deprecated.ignore"))) {
.Deprecated(msg = sprintf("Detected creation of a 'multiprocess' future. Strategy 'multiprocess' is deprecated in future (>= 1.20.0) [2020-10-30]. Instead, explicitly specify either 'multisession' (recommended) or 'multicore'. In the current R session, 'multiprocess' equals '%s'.", if (supportsMulticore()) "multicore" else "multisession"))
}

fun <- if (supportsMulticore(warn = TRUE)) multicore else multisession
fun(..., workers = workers, envir = envir)
.Deprecated(msg = sprintf("Detected creation of a 'multiprocess' future. Strategy 'multiprocess' is deprecated in future (>= 1.20.0) [2020-10-30]. Instead, explicitly specify either 'multisession' (recommended) or 'multicore'. Starting with future 1.31.0 [2023-01-??], 'multiprocess' is the same as 'sequential'."))
sequential(..., envir = envir)
}
class(multiprocess) <- c("multiprocess", "future", "function")
attr(multiprocess, "init") <- NA ## Set to FALSE/TRUE in .onLoad()
class(multiprocess) <- c("sequential", "uniprocess", "future", "function")
## future (> 1.30.0): 'multiprocess' always resolves to 'sequential'
attr(multiprocess, "init") <- FALSE
6 changes: 0 additions & 6 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@

## Set future options based on environment variables
update_package_options(debug = debug)

## Does multiprocess resolve to multisession? If so, then
## plan(multiprocess) should initiate the workers.
if (is.na(attr(multiprocess, "init", exact = TRUE))) {
attr(multiprocess, "init") <<- !supportsMulticore()
}

## Initiate the R session UUID, which will also set/update
## .GlobalEnv$.Random.seed.
Expand Down
5 changes: 2 additions & 3 deletions R/zzz.plan.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ plan <- local({
}

warn_about_multiprocess <- function(stack) {
warn_about_deprecated(stack, strategy = "multiprocess", fmtstr = sprintf("Strategy '%%s' is %%s in future (>= 1.20.0) [2020-10-30]. Instead, explicitly specify either 'multisession' (recommended) or 'multicore'. In the current R session, 'multiprocess' equals '%s'.", if (supportsMulticore()) "multicore" else "multisession"))
warn_about_deprecated(stack, strategy = "multiprocess", fmtstr = sprintf("Strategy '%%s' is %%s in future (>= 1.20.0) [2020-10-30]. Instead, explicitly specify either 'multisession' (recommended) or 'multicore'. Starting with future 1.31.0 [2023-01-??], 'multiprocess' is the same as 'sequential'."))
}

warn_about_remote <- function(stack) {
Expand Down Expand Up @@ -484,8 +484,7 @@ plan <- local({


supportedStrategies <- function(strategies = c("sequential", "multicore",
"multisession", "multiprocess",
"cluster")) {
"multisession", "cluster")) {
if (!supportsMulticore()) strategies <- setdiff(strategies, "multicore")
strategies
}
Expand Down
28 changes: 0 additions & 28 deletions incl/multiprocess.R

This file was deleted.

7 changes: 1 addition & 6 deletions man/multicore.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 4 additions & 48 deletions man/multiprocess.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions man/multisession.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/multiprocess.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ for (cores in 1:availCores) {
42L
})
print(f)
stopifnot(inherits(f, "MultiprocessFuture") || inherits(f, "SequentialFuture"))
stopifnot(inherits(f, "SequentialFuture"))

print(resolved(f))
y <- value(f)
Expand Down

0 comments on commit 9b632d8

Please sign in to comment.