Skip to content

Commit a48786c

Browse files
Merge branch 'release/0.6.0'
2 parents cdf2821 + 08d93e2 commit a48786c

27 files changed

+364
-58
lines changed

.Rbuildignore

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
^.svn
55
^.git
66
^.make
7-
INSTALL[.]md
8-
OVERVIEW[.]md
9-
README[.]md
10-
CONDUCT[.]md
7+
^INSTALL[.]md$
8+
^OVERVIEW[.]md$
9+
^README[.]md$
10+
^CONDUCT[.]md$
11+
12+
#----------------------------
13+
# devtools
14+
#----------------------------
15+
^revdep
1116

1217
#----------------------------
1318
# Travis-CI et al.
@@ -42,6 +47,12 @@ Rplots.pdf$
4247
#----------------------------
4348
# Package specific
4449
#----------------------------
45-
^[.]batchtools[.]R$
50+
^[.]BatchJobs[.]R$
4651
[.]future
4752

53+
#----------------------------
54+
# Miscellaneous
55+
#----------------------------
56+
^.ghi
57+
^.issues
58+

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Package: future.batchtools
2-
Version: 0.5.0
2+
Version: 0.6.0
33
Depends:
44
R (>= 3.2.0),
5-
future (>= 1.5.0)
5+
future (>= 1.6.1)
66
Imports:
7-
batchtools (>= 0.9.3)
7+
batchtools (>= 0.9.6)
88
Suggests:
99
listenv,
1010
markdown,

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ importFrom(batchtools,makeClusterFunctionsTORQUE)
4444
importFrom(batchtools,makeRegistry)
4545
importFrom(batchtools,removeRegistry)
4646
importFrom(batchtools,saveRegistry)
47+
importFrom(batchtools,setJobNames)
4748
importFrom(batchtools,submitJobs)
4849
importFrom(batchtools,waitForJobs)
4950
importFrom(future,Future)
@@ -59,3 +60,4 @@ importFrom(utils,capture.output)
5960
importFrom(utils,file_test)
6061
importFrom(utils,sessionInfo)
6162
importFrom(utils,str)
63+
importFrom(utils,tail)

NEWS

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
11
Package: future.batchtools
22
==========================
33

4+
Version: 0.6.0 [2017-09-10]
5+
6+
NEW FEATURES:
7+
8+
o If the built-in attempts of batchtools for finding a default template file
9+
fails, then system("templates", package = "future.batchtools") is searched
10+
for template files as well. Currently, there exists a `torque.tmpl` file.
11+
12+
o A job's name in the scheduler is now set as the future's label (requires
13+
batchtools 0.9.4 or newer). If no label is specified, the default job name
14+
is controlled by batchtools.
15+
16+
o The period between each poll of the scheduler to check whether a future
17+
(job) is finished or not now increases geometrically as a function of number
18+
of polls. This lowers the load on the scheduler for long running jobs.
19+
20+
o The error message for expired batchtools futures now include the last few
21+
lines of the logged output, which sometimes includes clues on why the future
22+
expired. For instance, if a TORQUE / PBS job use more than the allocated
23+
amount of memory it might be terminated by the scheduler leaving the message
24+
"PBS: job killed: vmem 1234000 exceeded limit 1048576" in the output.
25+
26+
o print() for BatchtoolsFuture returns the object invisibly.
27+
28+
BUG FIXES:
29+
30+
o Calling future_lapply() with functions containing globals part of non-default
31+
packages would when using batchtools futures give an error complaining that
32+
the global is missing. This was due to updates in future (>= 1.4.0) that
33+
broke this package.
34+
35+
o loggedOutput() for BatchtoolsFuture would always return NULL unless an error
36+
had occurred.
37+
38+
439
Version: 0.5.0 [2017-06-02]
540

641
o First version submitted to CRAN.
@@ -68,5 +103,5 @@ GLOBALS:
68103
Version: 0.1.0 [2017-02-11]
69104

70105
o Package created by porting the code of future.BatchJobs. This version passes
71-
'R CMD check --as-cran' with all OK after a minimial amount of adjustments
106+
'R CMD check --as-cran' with all OK after a minimal amount of adjustments
72107
to the ported code.

R/BatchtoolsFuture-class.R

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@
4242
#' @importFrom batchtools submitJobs
4343
#' @keywords internal
4444
BatchtoolsFuture <- function(expr = NULL, envir = parent.frame(),
45-
substitute = TRUE, globals = TRUE,
46-
label = "batchtools", cluster.functions = NULL,
45+
substitute = TRUE,
46+
globals = TRUE, packages = NULL,
47+
label = NULL, cluster.functions = NULL,
4748
resources = list(), workers = NULL,
4849
finalize = getOption("future.finalize", TRUE),
4950
...) {
@@ -77,7 +78,7 @@ BatchtoolsFuture <- function(expr = NULL, envir = parent.frame(),
7778
workers = workers, label = label, ...)
7879

7980
future$globals <- gp$globals
80-
future$packages <- gp$packages
81+
future$packages <- unique(c(packages, gp$packages))
8182

8283
## Create batchtools registry
8384
reg <- temp_registry(label = future$label)
@@ -131,6 +132,8 @@ print.BatchtoolsFuture <- function(x, ...) {
131132
printf("batchtools Registry:\n ")
132133
print(reg)
133134
}
135+
136+
invisible(x)
134137
}
135138

136139

@@ -237,8 +240,6 @@ loggedOutput.BatchtoolsFuture <- function(future, ...) {
237240
stop(BatchtoolsFutureError(msg, future = future))
238241
}
239242

240-
if (!"error" %in% stat) return(NULL)
241-
242243
config <- future$config
243244
reg <- config$reg
244245
jobid <- config$jobid
@@ -305,7 +306,7 @@ value.BatchtoolsFuture <- function(future, signal = TRUE,
305306
run <- function(...) UseMethod("run")
306307

307308
#' @importFrom future getExpression
308-
#' @importFrom batchtools batchExport batchMap saveRegistry
309+
#' @importFrom batchtools batchExport batchMap saveRegistry setJobNames
309310
run.BatchtoolsFuture <- function(future, ...) {
310311
if (future$state != "created") {
311312
label <- future$label
@@ -372,6 +373,12 @@ run.BatchtoolsFuture <- function(future, ...) {
372373
jobid <- batchMap(fun = geval, list(expr),
373374
more.args = list(substitute = TRUE), reg = reg)
374375

376+
## 1b. Set job name, if specified
377+
label <- future$label
378+
if (!is.null(label)) {
379+
setJobNames(ids = jobid, names = label, reg = reg)
380+
}
381+
375382
## 2. Update
376383
future$config$jobid <- jobid
377384
mdebug("Created %s future #%d", class(future)[1], jobid$job.id)
@@ -420,6 +427,8 @@ await <- function(...) UseMethod("await")
420427
#' success, otherwise not.
421428
#' @param timeout Total time (in seconds) waiting before generating an error.
422429
#' @param delta The number of seconds to wait between each poll.
430+
#' @param alpha A factor to scale up the waiting time in each iteration such
431+
#' that the waiting time in the k:th iteration is \code{alpha ^ k * delta}.
423432
#' @param \ldots Not used.
424433
#'
425434
#' @return The value of the evaluated expression.
@@ -433,16 +442,19 @@ await <- function(...) UseMethod("await")
433442
#'
434443
#' @export
435444
#' @importFrom batchtools getErrorMessages loadResult waitForJobs
445+
#' @importFrom utils tail
436446
#' @keywords internal
437447
await.BatchtoolsFuture <- function(future, cleanup = TRUE,
438448
timeout = getOption("future.wait.timeout",
439449
30 * 24 * 60 * 60),
440450
delta = getOption("future.wait.interval",
441451
1.0),
452+
alpha = getOption("future.wait.alpha", 1.01),
442453
...) {
443454
mdebug <- import_future("mdebug")
444455
stopifnot(is.finite(timeout), timeout >= 0)
445-
456+
stopifnot(is.finite(alpha), alpha > 0)
457+
446458
debug <- getOption("future.debug", FALSE)
447459

448460
expr <- future$expr
@@ -456,7 +468,10 @@ await.BatchtoolsFuture <- function(future, cleanup = TRUE,
456468
oopts <- options(batchtools.verbose = debug)
457469
on.exit(options(oopts))
458470

459-
res <- waitForJobs(ids = jobid, timeout = timeout, sleep = delta,
471+
## Sleep function - increases geometrically as a function of iterations
472+
sleep_fcn <- function(i) delta * alpha ^ (i - 1)
473+
474+
res <- waitForJobs(ids = jobid, timeout = timeout, sleep = sleep_fcn,
460475
stop.on.error = FALSE, reg = reg)
461476
mdebug("- batchtools::waitForJobs(): %s", res)
462477
stat <- status(future)
@@ -480,10 +495,19 @@ await.BatchtoolsFuture <- function(future, cleanup = TRUE,
480495
output = loggedOutput(future)))
481496
} else if ("expired" %in% stat) {
482497
cleanup <- FALSE
483-
msg <- sprintf("BatchtoolsExpiration: Future ('%s') expired: %s",
484-
label, reg$file.dir)
485-
stop(BatchtoolsFutureError(msg, future = future,
486-
output = loggedOutput(future)))
498+
msg <- sprintf("BatchtoolsExpiration: Future ('%s') expired (registry path %s).", label, reg$file.dir)
499+
output <- loggedOutput(future)
500+
hint <- unlist(strsplit(output, split = "\n", fixed = TRUE))
501+
hint <- hint[nzchar(hint)]
502+
hint <- tail(hint, n = 6L)
503+
if (length(hint) > 0) {
504+
hint <- paste(hint, collapse = "\n")
505+
msg <- sprintf("%s. The last few lines of the logged output:\n%s",
506+
msg, hint)
507+
} else {
508+
msg <- sprintf("%s. No logged output exist.", msg)
509+
}
510+
stop(BatchtoolsFutureError(msg, future = future, output = output))
487511
} else if (is_na(stat)) {
488512
msg <- sprintf("BatchtoolsDeleted: Cannot retrieve value. Future ('%s') deleted: %s", label, reg$file.dir) #nolint
489513
stop(BatchtoolsFutureError(msg, future = future))

R/batchtools_custom.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#' @export
1717
#' @importFrom utils file_test
1818
batchtools_custom <- function(expr, envir = parent.frame(), substitute = TRUE,
19-
globals = TRUE, label = "batchtools",
19+
globals = TRUE, label = NULL,
2020
cluster.functions,
2121
resources = list(), workers = NULL, ...) {
2222
if (substitute) expr <- substitute(expr)

R/batchtools_interactive.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' @export
55
batchtools_interactive <- function(expr, envir = parent.frame(),
66
substitute = TRUE, globals = TRUE,
7-
label = "batchtools", workers = 1L, ...) {
7+
label = NULL, workers = 1L, ...) {
88
if (substitute) expr <- substitute(expr)
99

1010
cf <- makeClusterFunctionsInteractive(external = FALSE)

R/batchtools_local.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#' @aliases batchtools_interactive
3737
#' @export
3838
batchtools_local <- function(expr, envir = parent.frame(), substitute = TRUE,
39-
globals = TRUE, label = "batchtools",
39+
globals = TRUE, label = NULL,
4040
workers = 1L, ...) {
4141
if (substitute) expr <- substitute(expr)
4242

R/batchtools_multicore.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#' @keywords internal
2828
batchtools_multicore <- function(expr, envir = parent.frame(),
2929
substitute = TRUE, globals = TRUE,
30-
label = "batchtools",
30+
label = NULL,
3131
workers = availableCores(constraints = "multicore"),
3232
...) {
3333
if (substitute) expr <- substitute(expr)

0 commit comments

Comments
 (0)