Skip to content

Commit

Permalink
Fix Rd issues
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Feb 9, 2025
1 parent 47383df commit 1587c5b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: doFuture
Version: 1.0.1-9007
Version: 1.0.1-9008
Title: Use Foreach to Parallelize via the Future Framework
Depends:
foreach (>= 1.5.0),
Expand Down
2 changes: 1 addition & 1 deletion R/doFuture-package.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' doFuture: Foreach Parallel Adapter using Futures
#'
#' The \pkg{doFuture} package provides mechanisms for using the
#' **[foreach]** package together with the **[future]** package
#' \pkg{foreach} package together with the \pkg{future} package
#' such that `foreach()` parallelizes via _any_ future backend.
#'
#' @section Usage:
Expand Down
6 changes: 3 additions & 3 deletions R/dofuture_OP.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @return The value of the foreach call.
#'
#' @details
#' This is a replacement for [`%dopar%`] of the \pkg{foreach} package
#' This is a replacement for `%dopar%` of the \pkg{foreach} package
#' that leverages the \pkg{future} framework.
#'
#' When using `%dofuture%`:
Expand Down Expand Up @@ -452,8 +452,8 @@ doFuture2 <- function(obj, expr, envir, data) { #nolint

## Search also %dofuture% expression alone, to pick up things
## like a <- a + 1, where 'a' is a global
## This was added to make future (> 1.34.0) backward compatible
## with future (<= 1.34.0) /HB 2025-02-08
## This was added to make future with evalFuture() backward compatible
## with previous versions of the 'future' package /HB 2025-02-08
if (getOption("doFuture.globals.scanVanillaExpression", TRUE)) {
if (debug) {
mdebug(" - R expression (%dofuture% expression searched for globals):")
Expand Down
17 changes: 14 additions & 3 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
future_has_evalFuture <- local({
res <- NULL
function() {
if (is.null(res)) {
ns <- getNamespace("future")
res <<- exists("evalFuture", mode = "function", envir = ns)
}
res
}
})

patch_expressions <- function() {
## Temporary patches for future (> 1.34.0)
## Temporary patches for future package with evalFuture()
patches <- getOption("doFuture.patches")
if (is.null(patches)) {
if (packageVersion("future") > "1.34.0") {
if (future_has_evalFuture()) {
## Package 'WARDEN'
if ("WARDEN" %in% loadedNamespaces()) {
patches <- c(patches, "WARDEN")
Expand Down Expand Up @@ -41,7 +52,7 @@ patch_expressions <- function() {
if (is.null(value)) {
value <- Sys.getenv("R_DOFUTURE_GLOBALS_SCANVANILLAEXPRESSION", NA_character_)
if (is.na(value)) {
value <- (packageVersion("future") > "1.34.0")
value <- future_has_evalFuture()
} else {
value <- trim(value)
value <- suppressWarnings(as.logical(value))
Expand Down
2 changes: 1 addition & 1 deletion man/doFuture.Rd

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

2 changes: 1 addition & 1 deletion man/grapes-dofuture-grapes.Rd

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

6 changes: 3 additions & 3 deletions tests/foreach_dofuture,globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ for (strategy in strategies) {
}
y <- tryCatch(sub(x, 2:3), error = identity)
str(y)
if (packageVersion("future") <= "1.34.0") {
stopifnot((strategy %in% c(c("cluster", "multisession")) && inherits(y, "simpleError")) || identical(y, y_truth))
} else {
if (doFuture:::future_has_evalFuture()) {
stopifnot(inherits(y, "simpleError"))
} else {
stopifnot((strategy %in% c(c("cluster", "multisession")) && inherits(y, "simpleError")) || identical(y, y_truth))
}

# Shutdown current plan
Expand Down

0 comments on commit 1587c5b

Please sign in to comment.