Skip to content

Commit 1a63b80

Browse files
run() for BatchtoolsFuture now produce an informative BatchtoolsFutureError in case batchtools::submitJobs() fails
1 parent 678645f commit 1a63b80

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: future.batchtools
2-
Version: 0.10.0-9033
2+
Version: 0.10.0-9034
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
file (a shell script) with info on location, file size, and number
2626
of lines, if they exist.
2727

28+
* `run()` for BatchtoolsFuture now produce an informative
29+
BatchtoolsFutureError in case `batchtools::submitJobs()` fails, for
30+
instance, due to invalid job-scheduler rsource specifications.
31+
2832
* Add BatchtoolsFuture subclasses; abstract
2933
BatchtoolsUniprocessFuture, abstract BatchtoolsMultiprocessFuture,
3034
BatchtoolsInteractiveFuture, BatchtoolsLocalFuture,

R/BatchtoolsFuture-class.R

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ result.BatchtoolsFuture <- function(future, cleanup = TRUE, ...) {
383383

384384
#' @importFrom future run getExpression
385385
#' @importFrom batchtools batchExport batchMap saveRegistry setJobNames submitJobs
386+
#' @importFrom utils capture.output str
386387
#' @export
387388
run.BatchtoolsFuture <- function(future, ...) {
388389
if (future$state != "created") {
@@ -517,8 +518,19 @@ run.BatchtoolsFuture <- function(future, ...) {
517518

518519
## WORKAROUND: batchtools::submitJobs() updates the RNG state,
519520
## which we must make sure to undo.
520-
with_stealth_rng({
521-
submitJobs(reg = reg, ids = jobid, resources = resources)
521+
tryCatch({
522+
with_stealth_rng({
523+
submitJobs(reg = reg, ids = jobid, resources = resources)
524+
})
525+
}, error = function(ex) {
526+
msg <- conditionMessage(ex)
527+
label <- future$label
528+
if (is.null(label)) label <- "<none>"
529+
msg <- sprintf("Failed to submit %s (%s). The reason was: %s", class(future)[1], label, msg)
530+
info <- capture.output(str(resources))
531+
info <- paste(info, collapse = "\n")
532+
msg <- sprintf("%s\nTROUBLESHOOTING INFORMATION:\nbatchtools::submitJobs() was called with the following 'resources' argument:\n%s\n", msg, info)
533+
stop(BatchtoolsFutureError(msg, future = future))
522534
})
523535

524536
mdebugf("Launched future #%d", jobid$job.id)

0 commit comments

Comments
 (0)