Skip to content

Commit 714cf6c

Browse files
Print plan() for 'batchtools_slurm' reports on Slurm version
1 parent a3ec0fb commit 714cf6c

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
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.12.2-9969
2+
Version: 0.12.2-9970
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ S3method(nbrOfWorkers,BatchtoolsUniprocessFutureBackend)
1515
S3method(print,BatchtoolsFuture)
1616
S3method(print,BatchtoolsFutureBackend)
1717
S3method(print,BatchtoolsSGEFutureBackend)
18+
S3method(print,BatchtoolsSlurmFutureBackend)
1819
S3method(registerFuture,BatchtoolsFuture)
1920
S3method(registerFuture,BatchtoolsUniprocessFuture)
2021
S3method(registerFuture,default)

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
specified, corresponding `module load <name>` entries are injected
3434
to the job script.
3535

36-
* Print `plan()` for `batchtools_sge` reports on SGE version.
36+
* Calling `plan()` on `batchtools_sge` and `batchtools_slurm` reports
37+
on the version of the scheduler.
3738

3839
## Documentation
3940

R/batchtools_slurm.R

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ BatchtoolsSlurmFutureBackend <- function(...) {
77
}
88

99

10+
#' @export
11+
#' @keywords internal
12+
print.BatchtoolsSlurmFutureBackend <- function(x, ...) {
13+
NextMethod()
14+
printf("Slurm version: %s\n", slurm_version())
15+
invisible(x)
16+
}
17+
18+
1019
#' A batchtools slurm backend resolves futures in parallel via a Slurm job scheduler
1120
#'
1221
#' @inheritParams BatchtoolsTemplateFutureBackend
@@ -80,3 +89,29 @@ attr(batchtools_slurm, "tweakable") <- c(
8089
)
8190
attr(batchtools_slurm, "init") <- TRUE
8291
attr(batchtools_slurm, "factory") <- BatchtoolsSlurmFutureBackend
92+
93+
94+
slurm_version <- local({
95+
version <- NULL
96+
97+
function() {
98+
if (is.null(version)) {
99+
out <- tryCatch(system2("scontrol", args = c("--version"), stdout = TRUE, stderr = TRUE), error = identity)
100+
if (inherits(out, "error")) {
101+
version <<- "N/A (unexpected output from 'scontrol --version')"
102+
} else {
103+
status <- attr(out, "status")
104+
if (!is.null(status) && status != 0) {
105+
version <<- "N/A (unexpected output from 'scontrol --version')"
106+
} else {
107+
out <- gsub("(^[[:blank:]]+|[[:blank:]]+$)", "", out)
108+
out <- out[nzchar(out)]
109+
if (length(out) >= 1) {
110+
version <<- out[1]
111+
}
112+
}
113+
}
114+
}
115+
version
116+
}
117+
})

0 commit comments

Comments
 (0)