Skip to content

Commit c00a27c

Browse files
CLEANUP:
Use commaq() in more places stopifnot() -> stop_if_not()
1 parent 3accc5a commit c00a27c

13 files changed

+47
-51
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: future
2-
Version: 1.34.0-9121
2+
Version: 1.34.0-9122
33
Title: Unified Parallel and Distributed Processing in R for Everyone
44
Imports:
55
digest,

R/000.import.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ import_parallelly <- function(...) {
1414
}
1515

1616

17-
## Keep until future.batchtools (> 0.11.0) is on CRAN
18-
inRCmdCheck <- import_parallelly("inRCmdCheck")
19-
20-
2117
## We are currently importing the following non-exported functions:
2218
## * cluster futures:
2319
## - parallel:::defaultCluster() ## non-critical / not really needed /

R/ClusterFuture-class.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ as_ClusterFuture <- function(future, workers = NULL, ...) {
6060
workers <- addCovrLibPath(workers)
6161
}
6262
if (!inherits(workers, "cluster")) {
63-
stopf("Argument 'workers' is not of class 'cluster': %s", paste(sQuote(class(workers)), collapse = ", "))
63+
stopf("Argument 'workers' is not of class 'cluster': %s", commaq(class(workers)))
6464
}
6565
stop_if_not(length(workers) > 0)
6666

R/Future-class.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ print.Future <- function(x, ...) {
233233
exclude <- attr(x$conditions, "exclude", exact = TRUE)
234234
if (length(exclude) == 0) exclude <- "nothing"
235235
cat(sprintf("Capture condition classes: %s (excluding %s)\n",
236-
paste(sQuote(x$conditions), collapse = ", "),
237-
paste(sQuote(exclude), collapse = ", ")))
236+
commaq(x$conditions),
237+
commaq(exclude)))
238238
} else {
239239
cat("Capture condition classes: <none>\n")
240240
}
@@ -259,7 +259,7 @@ print.Future <- function(x, ...) {
259259
p <- packages(x)
260260
np <- length(p)
261261
if (np > 0) {
262-
cat(sprintf("Packages: %d packages (%s)\n", np, paste(sQuote(p), collapse = ", ")))
262+
cat(sprintf("Packages: %d packages (%s)\n", np, commaq(p)))
263263
} else {
264264
cat("Packages: <none>\n")
265265
}
@@ -311,7 +311,7 @@ print.Future <- function(x, ...) {
311311
}
312312
cat(sprintf("Early signaling: %s\n", isTRUE(x$earlySignal)))
313313
cat(sprintf("Owner process: %s\n", x$owner))
314-
cat(sprintf("Class: %s\n", paste(sQuote(class), collapse = ", ")))
314+
cat(sprintf("Class: %s\n", commaq(class)))
315315
} ## print()
316316

317317

@@ -385,7 +385,7 @@ run.Future <- function(future, ...) {
385385

386386
## Create temporary future for a specific backend, but don't launch it
387387
makeFuture <- plan("next")
388-
if (debug) mdebug("- Future backend: ", paste(sQuote(class(makeFuture)), collapse = ", "))
388+
if (debug) mdebug("- Future backend: ", commaq(class(makeFuture)))
389389

390390
## AD HOC/WORKAROUND: /HB 2020-12-21
391391
args <- list(
@@ -418,7 +418,7 @@ run.Future <- function(future, ...) {
418418
}
419419
}
420420

421-
if (debug) mdebug("- Future class: ", paste(sQuote(class(tmpFuture)), collapse = ", "))
421+
if (debug) mdebug("- Future class: ", commaq(class(tmpFuture)))
422422

423423
## AD HOC/SPECIAL:
424424
## If 'earlySignal=TRUE' was set explicitly when creating the future,
@@ -687,7 +687,7 @@ getExpression.Future <- local({
687687
## Packages needed by the future
688688
pkgs <- packages(future)
689689
if (length(pkgs) > 0) {
690-
if (debug) mdebugf("Packages needed by the future expression (n = %d): %s", length(pkgs), paste(sQuote(pkgs), collapse = ", "))
690+
if (debug) mdebugf("Packages needed by the future expression (n = %d): %s", length(pkgs), commaq(pkgs))
691691
} else {
692692
if (debug) mdebug("Packages needed by the future expression (n = 0): <none>")
693693
}
@@ -711,7 +711,7 @@ getExpression.Future <- local({
711711
pkgsS <- unique(unlist(pkgsS, use.names = FALSE))
712712
## CLEANUP: Only keep those that are loaded in the current session
713713
pkgsS <- intersect(pkgsS, loadedNamespaces())
714-
if (debug) mdebugf("Packages needed by future strategies (n = %d): %s", length(pkgsS), paste(sQuote(pkgsS), collapse = ", "))
714+
if (debug) mdebugf("Packages needed by future strategies (n = %d): %s", length(pkgsS), commaq(pkgsS))
715715
pkgs <- unique(c(pkgs, pkgsS))
716716
}
717717

R/FutureCondition-class.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ GlobalEnvFutureCondition <- function(message = NULL, call = NULL, globalenv = gl
188188
if (is.null(message)) {
189189
label <- future$label
190190
if (is.null(label)) label <- "<none>"
191-
message <- sprintf("Future (%s) added variables to the global environment. A future expression should never assign variables to the global environment - neither by assign() nor by <<-: [n=%d] %s", label, length(globalenv$added), paste(sQuote(globalenv$added), collapse = ", "))
191+
message <- sprintf("Future (%s) added variables to the global environment. A future expression should never assign variables to the global environment - neither by assign() nor by <<-: [n=%d] %s", label, length(globalenv$added), commaq(globalenv$added))
192192
}
193193
cond <- FutureCondition(message = message, call = call, uuid = uuid, future = future)
194194
cond$globalenv <- globalenv

R/expressions.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ evalFuture <- function(
7070

7171
if (is.function(strategiesR)) {
7272
if (!inherits(strategiesR, "future")) {
73-
stop(FutureEvalError(sprintf("Argument 'strategiesR' is a function, but does not inherit 'future': %s", paste(sQuote(class(strategiesR)), collapse = ", "))))
73+
stop(FutureEvalError(sprintf("Argument 'strategiesR' is a function, but does not inherit 'future': %s", commaq(class(strategiesR)))))
7474
}
7575
} else if (is.list(strategiesR)) {
7676
for (kk in seq_along(strategiesR)) {
7777
strategy <- strategiesR[[kk]]
7878
if (!inherits(strategy, "future")) {
79-
stop(FutureEvalError(sprintf("Element #%d of list 'strategiesR' is a function, but does not inherit 'future': %s", kk, paste(sQuote(class(strategy)), collapse = ", "))))
79+
stop(FutureEvalError(sprintf("Element #%d of list 'strategiesR' is a function, but does not inherit 'future': %s", kk, commaq(class(strategy)))))
8080
}
8181
}
8282
} else if (is.character(strategiesR)) {
8383
} else {
84-
stop(FutureEvalError(sprintf("Unknown value of argument 'strategiesR': %s", paste(sQuote(class(strategiesR)), collapse = ", "))))
84+
stop(FutureEvalError(sprintf("Unknown value of argument 'strategiesR': %s", commaq(class(strategiesR)))))
8585
}
8686

8787
## Start time for future evaluation
@@ -289,7 +289,7 @@ evalFuture <- function(
289289

290290
## Options forwarded from parent process
291291
if (length(forwardOptions) > 0) {
292-
stopifnot(!is.null(names(forwardOptions)))
292+
stop_if_not(!is.null(names(forwardOptions)))
293293
do.call(options, args = forwardOptions)
294294
}
295295

R/globals.R

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ getGlobalsAndPackages <- function(expr, envir = parent.frame(), tweak = tweakExp
7171
if (is.character(add)) {
7272
if (debug) mdebug("Retrieving 'add' globals ...")
7373
add <- globalsByName(add, envir = envir, mustExist = mustExist)
74-
if (debug) mdebugf("- 'add' globals retrieved: [%d] %s", length(add), paste(sQuote(names(add)), collapse = ", "))
74+
if (debug) mdebugf("- 'add' globals retrieved: [%d] %s", length(add), commaq(names(add)))
7575
if (debug) mdebug("Retrieving 'add' globals ... DONE")
7676
} else if (inherits(add, "Globals")) {
77-
if (debug) mdebugf("- 'add' globals passed as-is: [%d] %s", length(add), paste(sQuote(names(add)), collapse = ", "))
77+
if (debug) mdebugf("- 'add' globals passed as-is: [%d] %s", length(add), commaq(names(add)))
7878
} else if (is.list(add)) {
79-
if (debug) mdebugf("- 'add' globals passed as-list: [%d] %s", length(add), paste(sQuote(names(add)), collapse = ", "))
79+
if (debug) mdebugf("- 'add' globals passed as-list: [%d] %s", length(add), commaq(names(add)))
8080
} else {
8181
stopf("Attribute 'add' of argument 'globals' must be either a character vector or a named list: %s", mode(add))
8282
}
@@ -113,7 +113,7 @@ getGlobalsAndPackages <- function(expr, envir = parent.frame(), tweak = tweakExp
113113
mustExist = mustExist,
114114
recursive = TRUE
115115
)
116-
if (debug) mdebugf("- globals found: [%d] %s", length(globals), paste(sQuote(names(globals)), collapse = ", "))
116+
if (debug) mdebugf("- globals found: [%d] %s", length(globals), commaq(names(globals)))
117117
if (debug) mdebug("Searching for globals ... DONE")
118118
} else {
119119
if (debug) mdebug("Not searching for globals")
@@ -135,12 +135,12 @@ getGlobalsAndPackages <- function(expr, envir = parent.frame(), tweak = tweakExp
135135
} else if (is.character(globals)) {
136136
if (debug) mdebug("Retrieving globals ...")
137137
globals <- globalsByName(globals, envir = envir, mustExist = mustExist)
138-
if (debug) mdebugf("- globals retrieved: [%d] %s", length(globals), paste(sQuote(names(globals)), collapse = ", "))
138+
if (debug) mdebugf("- globals retrieved: [%d] %s", length(globals), commaq(names(globals)))
139139
if (debug) mdebug("Retrieving globals ... DONE")
140140
} else if (inherits(globals, "Globals")) {
141-
if (debug) mdebugf("- globals passed as-is: [%d] %s", length(globals), paste(sQuote(names(globals)), collapse = ", "))
141+
if (debug) mdebugf("- globals passed as-is: [%d] %s", length(globals), commaq(names(globals)))
142142
} else if (is.list(globals)) {
143-
if (debug) mdebugf("- globals passed as-list: [%d] %s", length(globals), paste(sQuote(names(globals)), collapse = ", "))
143+
if (debug) mdebugf("- globals passed as-list: [%d] %s", length(globals), commaq(names(globals)))
144144
} else {
145145
stopf("Argument 'globals' must be either a logical scalar or a character vector: %s", mode(globals))
146146
}
@@ -300,14 +300,14 @@ getGlobalsAndPackages <- function(expr, envir = parent.frame(), tweak = tweakExp
300300

301301
## Nothing to do?
302302
if (length(idxs) > 0) {
303-
if (debug) mdebugf("Global futures (not constant): %s", paste(sQuote(names(globals[idxs])), collapse = ", "))
303+
if (debug) mdebugf("Global futures (not constant): %s", commaq(names(globals[idxs])))
304304
valuesF <- value(globals[idxs])
305305
globals[idxs] <- lapply(valuesF, FUN = ConstantFuture)
306306
}
307307
}
308308

309309
if (debug) {
310-
mdebugf("- globals: [%d] %s", length(globals), paste(sQuote(names(globals)), collapse = ", "))
310+
mdebugf("- globals: [%d] %s", length(globals), commaq(names(globals)))
311311
mdebug("Resolving any globals that are futures ... DONE")
312312
}
313313
}
@@ -326,7 +326,7 @@ getGlobalsAndPackages <- function(expr, envir = parent.frame(), tweak = tweakExp
326326
## Append packages associated with globals
327327
pkgs <- packagesOf(globals)
328328
if (debug) {
329-
mdebugf(" - Packages associated with globals: [%d] %s", length(pkgs), paste(sQuote(pkgs), collapse = ", "))
329+
mdebugf(" - Packages associated with globals: [%d] %s", length(pkgs), commaq(pkgs))
330330
}
331331

332332
## Drop all globals which are located in one of
@@ -355,7 +355,7 @@ getGlobalsAndPackages <- function(expr, envir = parent.frame(), tweak = tweakExp
355355
globals <- cleanup(globals)
356356
}
357357
if (debug) {
358-
mdebugf(" - Packages: [%d] %s", length(pkgs), paste(sQuote(pkgs), collapse = ", "))
358+
mdebugf(" - Packages: [%d] %s", length(pkgs), commaq(pkgs))
359359
mdebugf("- Search for packages associated with the globals ... DONE")
360360
}
361361

@@ -377,7 +377,7 @@ getGlobalsAndPackages <- function(expr, envir = parent.frame(), tweak = tweakExp
377377
if (debug) mdebug("Resolving futures part of globals (recursively) ...")
378378
globals <- resolve(globals, result = TRUE, recursive = TRUE)
379379
if (debug) {
380-
mdebugf("- globals: [%d] %s", length(globals), paste(sQuote(names(globals)), collapse = ", "))
380+
mdebugf("- globals: [%d] %s", length(globals), commaq(names(globals)))
381381
mdebug("Resolving futures part of globals (recursively) ... DONE")
382382
}
383383
}
@@ -424,7 +424,7 @@ getGlobalsAndPackages <- function(expr, envir = parent.frame(), tweak = tweakExp
424424
## available for all R sessions / implementations.
425425
pkgs <- setdiff(pkgs, "base")
426426
if (debug) {
427-
mdebugf("- Packages after dropping 'base': [%d] %s", length(pkgs), paste(sQuote(pkgs), collapse = ", "))
427+
mdebugf("- Packages after dropping 'base': [%d] %s", length(pkgs), commaq(pkgs))
428428
}
429429
if (length(pkgs) > 0L) {
430430
## Local functions
@@ -441,7 +441,7 @@ getGlobalsAndPackages <- function(expr, envir = parent.frame(), tweak = tweakExp
441441
isAttached <- is.element(pkgs, attachedPackages())
442442
pkgs <- pkgs[isAttached]
443443

444-
mdebugf("- Packages after dropping non-attached packages: [%d] %s", length(pkgs), paste(sQuote(pkgs), collapse = ", "))
444+
mdebugf("- Packages after dropping non-attached packages: [%d] %s", length(pkgs), commaq(pkgs))
445445
}
446446

447447
keepWhere <- getOption("future.globals.keepWhere", FALSE)
@@ -452,8 +452,8 @@ getGlobalsAndPackages <- function(expr, envir = parent.frame(), tweak = tweakExp
452452
}
453453

454454
if (debug) {
455-
mdebugf("- globals: [%d] %s", length(globals), paste(sQuote(names(globals)), collapse = ", "))
456-
mdebugf("- packages: [%d] %s", length(pkgs), paste(sQuote(pkgs), collapse = ", "))
455+
mdebugf("- globals: [%d] %s", length(globals), commaq(names(globals)))
456+
mdebugf("- packages: [%d] %s", length(pkgs), commaq(pkgs))
457457
mdebug("getGlobalsAndPackages() ... DONE")
458458
}
459459

R/nbrOfWorkers.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ nbrOfWorkers.cluster <- function(evaluator) {
3030
} else if (inherits(workers, "cluster")) {
3131
workers <- length(workers)
3232
} else {
33-
stopf("Unsupported type of 'workers' for evaluator of class %s: %s", paste(sQuote(class(evaluator)), collapse = ", "), class(workers)[1])
33+
stopf("Unsupported type of 'workers' for evaluator of class %s: %s", commaq(class(evaluator)), class(workers)[1])
3434
}
3535
stop_if_not(length(workers) == 1L, !is.na(workers), workers >= 1L, is.finite(workers))
3636

@@ -54,7 +54,7 @@ nbrOfWorkers.multiprocess <- function(evaluator) {
5454
if (is.function(workers)) workers <- workers()
5555
if (is.numeric(workers)) {
5656
} else {
57-
stopf("Unsupported type of 'workers' for evaluator of class %s: %s", paste(sQuote(class(evaluator)), collapse = ", "), class(workers)[1])
57+
stopf("Unsupported type of 'workers' for evaluator of class %s: %s", commaq(class(evaluator)), class(workers)[1])
5858
}
5959
stop_if_not(length(workers) == 1L, !is.na(workers), workers >= 1L, is.finite(workers))
6060

@@ -72,7 +72,7 @@ nbrOfWorkers.future <- function(evaluator) {
7272
} else if (is.null(workers)) {
7373
workers <- Inf
7474
} else {
75-
stopf("Unsupported type of 'workers' for evaluator of class %s: %s", paste(sQuote(class(evaluator)), collapse = ", "), class(workers)[1])
75+
stopf("Unsupported type of 'workers' for evaluator of class %s: %s", commaq(class(evaluator)), class(workers)[1])
7676
}
7777
stop_if_not(length(workers) == 1L, !is.na(workers), workers >= 1L)
7878

@@ -153,7 +153,7 @@ nbrOfFreeWorkers.multicore <- function(evaluator, background = FALSE, ...) {
153153

154154
#' @export
155155
nbrOfFreeWorkers.multiprocess <- function(evaluator, background = FALSE, ...) {
156-
stopf("nbrOfFreeWorkers() is not implemented for this type of future backend (please contacts the maintainer of that backend): %s", paste(sQuote(class(evaluator)), collapse = ", "))
156+
stopf("nbrOfFreeWorkers() is not implemented for this type of future backend (please contacts the maintainer of that backend): %s", commaq(class(evaluator)))
157157
}
158158

159159
#' @export
@@ -163,7 +163,7 @@ nbrOfFreeWorkers.future <- function(evaluator, background = FALSE, ...) {
163163
workers <- nbrOfWorkers(evaluator)
164164
if (is.infinite(workers)) return(workers)
165165

166-
stopf("nbrOfFreeWorkers() is not implemented for this type of future backend (please contacts the maintainer of that backend): %s", paste(sQuote(class(evaluator)), collapse = ", "))
166+
stopf("nbrOfFreeWorkers() is not implemented for this type of future backend (please contacts the maintainer of that backend): %s", commaq(class(evaluator)))
167167
}
168168

169169

R/tweak.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ tweak.future <- function(strategy, ..., penvir = parent.frame()) {
8282
untweakable <- getOption("future.tweak.untweakable", untweakable)
8383
if (any(names %in% untweakable)) {
8484
untweakable <- intersect(names, untweakable)
85-
untweakable <- paste(sQuote(untweakable), collapse = ", ")
85+
untweakable <- commaq(untweakable)
8686
stopf("Detected arguments that must not be set via plan() or tweak(): %s",
8787
untweakable)
8888
}
@@ -97,7 +97,7 @@ tweak.future <- function(strategy, ..., penvir = parent.frame()) {
9797
known <- c(formals, names(formals(future)), tweakable)
9898
unknown <- setdiff(names, known)
9999
if (length(unknown) > 0L) {
100-
warnf("Detected %d unknown future arguments: %s", length(unknown), paste(sQuote(unknown), collapse = ", "))
100+
warnf("Detected %d unknown future arguments: %s", length(unknown), commaq(unknown))
101101
}
102102

103103
strategy2 <- function(...) NULL

R/utils-immediateCondition.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ save_rds <- function(object, pathname, ...) {
150150
ex$message <- msg
151151
stop(ex)
152152
})
153-
stopifnot(file_test("-f", pathname_tmp))
153+
stop_if_not(file_test("-f", pathname_tmp))
154154

155155
res <- file.rename(from = pathname_tmp, to = pathname)
156156

0 commit comments

Comments
 (0)