Skip to content

Commit 997274a

Browse files
Merge branch 'release/1.1.3'
2 parents 0f68027 + 2d8af09 commit 997274a

30 files changed

+103
-36
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020
- {os: windows-latest, r: 'release' }
2121
- {os: windows-latest, r: 'oldrel' }
2222
# - {os: macOS-latest, r: 'devel' }
23-
- {os: macOS-latest, r: 'release', parallelly_version: ed860db, label: 'w/ compatible parallelly' }
24-
- {os: macOS-latest, r: 'release', parallelly_version: ea182e9, label: 'w/ compatible parallelly' }
2523
- {os: macOS-latest, r: 'release' }
2624
- {os: macOS-latest, r: 'oldrel' }
2725
# - {os: ubuntu-latest, r: 'devel' }
@@ -33,9 +31,7 @@ jobs:
3331
- {os: ubuntu-latest, r: 'release' , plan: multicore, label: 'w/ multicore' }
3432
- {os: ubuntu-latest, r: 'release' , plan: multisession, label: 'w/ multisession' }
3533
- {os: windows-latest, r: 'release', future_version: develop, label: 'w/ future-develop' }
36-
- {os: windows-latest, r: 'release', globals_version: develop, future_version: develop, label: 'w/ future-develop' }
3734
- {os: ubuntu-latest, r: 'release', future_version: develop, label: 'w/ future-develop' }
38-
- {os: ubuntu-latest, r: 'release', globals_version: develop, future_version: develop, label: 'w/ future-develop' }
3935

4036
env:
4137
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: doFuture
2-
Version: 1.1.2
2+
Version: 1.1.3
33
Title: Use Foreach to Parallelize via the Future Framework
44
Depends:
55
foreach (>= 1.5.0),
@@ -27,5 +27,5 @@ URL: https://doFuture.futureverse.org, https://github.com/futureverse/doFuture
2727
BugReports: https://github.com/futureverse/doFuture/issues
2828
Language: en-US
2929
Encoding: UTF-8
30-
RoxygenNote: 7.3.2
30+
RoxygenNote: 7.3.3
3131
Roxygen: list(markdown = TRUE)

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Version 1.1.3 (2025-12-08)
2+
3+
## Bug Fixes
4+
5+
* Attempts to add or ignore globals via `foreach()` argument
6+
`.options.globals` were silently ignored.
7+
8+
19
# Version 1.1.2 (2025-07-14)
210

311
## Bug Fixes

R/doFuture2.R

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,6 @@ doFuture2 <- function(obj, expr, envir, data) { #nolint
273273

274274
globals <- options[["globals"]]
275275
if (is.null(globals)) globals <- TRUE
276-
if (is.logical(globals)) {
277-
attr(globals, "add") <- obj$export
278-
attr(globals, "ignore") <- obj$noexport
279-
} else {
280-
attr(globals, "add") <- c(attr(globals, "add", exact = TRUE), obj$export)
281-
attr(globals, "ignore") <- c(attr(globals, "ignore", exact = TRUE), obj$noexport)
282-
}
283276

284277
packages <- c(options[["packages"]], obj$packages)
285278

R/options.R

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,24 @@
1010
#'
1111
#' \describe{
1212
#' \item{\option{doFuture.foreach.export}:}{
13-
#' Specifies to what extent the \code{.export} argument of
14-
#' \code{\link[foreach]{foreach}()} should be respected or if globals
15-
#' should be automatically identified.
13+
#' Specifies to what extent the `.export` argument of [foreach()], paired
14+
#' with \code{\link[foreach:\%dopar\%]{\%dopar\%}}, should be respected or
15+
#' if globals should be automatically identified. This is only for
16+
#' `%dopar%` -- [`%dofuture%`] does not support `.export` and `.noexport`.
1617
#'
17-
#' If \code{".export"}, then the globals specified by the \code{.export}
18+
#' If `".export"`, then the globals specified by the `.export`
1819
#' argument will be used "as is".
1920
#'
20-
#' If \code{".export-and-automatic"}, then globals specified by
21-
#' \code{.export} as well as those automatically identified are used.
21+
#' If `".export-and-automatic"`, then globals specified by
22+
#' `.export` as well as those automatically identified are used.
2223
#'
23-
#' The \code{".export-and-automatic-with-warning"} is the same as
24-
#' \code{".export-and-automatic"}, but produces a warning if \code{.export}
25-
#' lacks some of the globals that the automatic identification locates
26-
#' - this is helpful feedback to developers using \code{foreach()}.
24+
#' The `".export-and-automatic-with-warning"` is the same as
25+
#' `".export-and-automatic"`, but produces a warning if `.export`
26+
#' lacks some of the globals that the automatic identification locates,
27+
#' which could be helpful feedback to developers using [foreach()] with
28+
#' `%dopar%` -- also when using adapters such as **doParallel**.
2729
#'
28-
#' (Default: \code{".export-and-automatic"})
30+
#' (Default: `".export-and-automatic"`)
2931
#' }
3032
#'
3133
#' \item{\option{doFuture.debug}:}{If `TRUE`, extensive debug messages are
@@ -34,7 +36,7 @@
3436
#'
3537
#' @section Environment variables that set R options:
3638
#' All of the above \R \option{doFfuture.*} options can be set by
37-
#' corresponding environment variable \env{R_FOFUTURE_*} _when the
39+
#' corresponding environment variable \env{R_DOFUTURE_*} _when the
3840
#' \pkg{doFuture} package is loaded_.
3941
#' For example, if `R_DOFUTURE_DEBUG=TRUE`, then option
4042
#' \option{doFuture.debug} is set to `TRUE` (logical).

inst/testme/deploy.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ for (kk in seq_along(files)) {
6262

6363
## Generate R unit test script
6464
code <- c(
65+
"#! /usr/bin/env Rscript",
6566
sprintf("## This runs testme test script inst/testme/test-%s.R", name),
6667
"## Don't edit - it was autogenerated by inst/testme/deploy.R",
6768
sprintf('%s:::testme("%s")', pkgname, name)
6869
)
6970
writeLines(code, con = target_file)
71+
Sys.chmod(target_file, mode = "0755")
7072
}
7173

7274
message(sprintf("Deploying %d test scripts ... done", length(files)))

inst/testme/test-foreach_dofuture,globals.R

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
library(doFuture)
66
options(
7-
parallelly.debug = TRUE,
8-
future.debug = TRUE,
9-
doFuture.debug = TRUE
7+
# parallelly.debug = TRUE,
8+
# future.debug = TRUE,
9+
# doFuture.debug = TRUE
1010
)
1111

1212
strategies <- future:::supportedStrategies()
@@ -129,6 +129,50 @@ for (strategy in strategies) {
129129
str(z1)
130130
stopifnot(identical(z1, z0))
131131

132+
message("- foreach() - globals are picked up ...")
133+
y <- foreach(x = 0) %dofuture% {
134+
message(sprintf("Globals: a = %s, b = %s", a, b))
135+
y ~ a + b
136+
}
137+
stopifnot(is.list(y), length(y) == 1L, inherits(y[[1]], "formula"))
138+
139+
message("- foreach() - .export and .noexport must not be used ...")
140+
y <- tryCatch({
141+
foreach(x = 0, .export = c("a", "b")) %dofuture% {
142+
message(sprintf("Globals: a = %s, b = %s", a, b))
143+
y ~ a + b
144+
}
145+
}, error = identity)
146+
stopifnot(inherits(y, "error"))
147+
148+
y <- tryCatch({
149+
foreach(x = 0, .noexport = c("a", "b")) %dofuture% {
150+
message(sprintf("Globals: a = %s, b = %s", a, b))
151+
y ~ a + b
152+
}
153+
}, error = identity)
154+
stopifnot(inherits(y, "error"))
155+
156+
message("- foreach() - globals can be added ...")
157+
y <- tryCatch({
158+
foreach(x = 0, .options.future = list(globals = structure(TRUE, add = c("a", "b")))) %dofuture% {
159+
message(sprintf("Globals: a = %s, b = %s", get("a"), get("b")))
160+
y ~ 42
161+
}
162+
}, error = identity)
163+
stopifnot(is.list(y), length(y) == 1L, inherits(y[[1]], "formula"))
164+
165+
message("- foreach() - globals can be ignored ...")
166+
y <- tryCatch({
167+
foreach(x = 0, .options.future = list(globals = structure(TRUE, ignore = c("a", "b")))) %dofuture% {
168+
message(sprintf("Globals: a = %s, b = %s", a, b))
169+
y ~ a + b
170+
}
171+
}, error = identity)
172+
stopifnot(
173+
inherits(y, "error") || inherits(plan("next"), c("sequential", "multicore"))
174+
)
175+
132176
# Shutdown current plan
133177
plan(sequential)
134178
} ## for (strategy ...)

man/doFuture.options.Rd

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test-foreach_dofuture,errors.R

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#! /usr/bin/env Rscript
12
## This runs testme test script inst/testme/test-foreach_dofuture,errors.R
23
## Don't edit - it was autogenerated by inst/testme/deploy.R
34
doFuture:::testme("foreach_dofuture,errors")

tests/test-foreach_dofuture,globals.R

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#! /usr/bin/env Rscript
12
## This runs testme test script inst/testme/test-foreach_dofuture,globals.R
23
## Don't edit - it was autogenerated by inst/testme/deploy.R
34
doFuture:::testme("foreach_dofuture,globals")

0 commit comments

Comments
 (0)