Skip to content

Commit a3ec0fb

Browse files
Print plan() for 'batchtools_sge' reports on SGE version
1 parent 0ca7efd commit a3ec0fb

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
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-9968
2+
Version: 0.12.2-9969
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ S3method(nbrOfWorkers,BatchtoolsMulticoreFutureBackend)
1414
S3method(nbrOfWorkers,BatchtoolsUniprocessFutureBackend)
1515
S3method(print,BatchtoolsFuture)
1616
S3method(print,BatchtoolsFutureBackend)
17+
S3method(print,BatchtoolsSGEFutureBackend)
1718
S3method(registerFuture,BatchtoolsFuture)
1819
S3method(registerFuture,BatchtoolsUniprocessFuture)
1920
S3method(registerFuture,default)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +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.
37+
3638
## Documentation
3739

3840
* Add `timeout <runtime> ...` to the default `batchtools_bash`

R/BatchtoolsFutureBackend-class.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ print.BatchtoolsFutureBackend <- function(x, ...) {
151151
path <- future_cache_path()
152152
printf("Cache directory: %s\n", dir_info(path))
153153

154+
printf("batchtools resources:\n")
155+
str(resources)
156+
154157
invisible(x)
155158
}
156159

R/batchtools_sge.R

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

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

0 commit comments

Comments
 (0)