Skip to content

Commit c342e4f

Browse files
makeClusterFunctionsSlurm2(): Patch runOSCommand() only for submitJob()
1 parent 74edf24 commit c342e4f

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
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.20.0-9013
2+
Version: 0.20.0-9014
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

R/BatchtoolsFutureBackend-class.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ status <- function(future, ...) {
542542
batch_id <- reg[["status"]][["batch.id"]]
543543
if (!is.null(batch_id)) {
544544
if (!is.character(batch_id) || length(batch_id) != 1L || is.na(batch_id) || !nzchar(batch_id) || !grepl("^[[:digit:].]+$", batch_id)) {
545-
stop(sprintf("Unknown value of 'batch.id': [class=%d] %s", class(batch_id)[1], paste(sQuote(batch_id), collapse = ", ")))
545+
stop(sprintf("Unknown value of 'batch.id': [class=%s] %s", class(batch_id)[1], paste(sQuote(batch_id), collapse = ", ")))
546546
}
547547
}
548548

R/makeClusterFutureSlurm2.R

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ patchClusterFunctionsSlurm2 <- function(cf) {
1212
nodename <- env[["nodename"]]
1313
org_listJobsQueued <- env[["listJobsQueued"]]
1414

15-
## Inject runOSCommand() that defaults to runOSCommand(..., stderr = FALSE)
16-
env[["runOSCommand"]] <- function(..., stderr = FALSE) {
15+
## Patch submitJob() to use runOSCommand(..., stderr = FALSE)
16+
## See https://github.com/mlr-org/batchtools/pull/314
17+
submitJob <- cf[["submitJob"]]
18+
env_submitJob <- new.env(parent = environment(submitJob))
19+
env_submitJob[["runOSCommand"]] <- function(..., stderr = FALSE) {
1720
debug <- isTRUE(getOption("future.batchtools.debug"))
1821
if (debug) {
1922
mdebugf_push("runOSCommand(..., stderr = FALSE) ...")
@@ -22,6 +25,8 @@ patchClusterFunctionsSlurm2 <- function(cf) {
2225
}
2326
runOSCommand(..., stderr = stderr)
2427
}
28+
environment(submitJob) <- env_submitJob
29+
cf[["submitJob"]] <- submitJob
2530

2631
## Allow for a 15-minute offset in time between host and Slurm's sacct server
2732
isJobQueued <- function(reg, batch_id, since = NULL, offset = 15*60) {
@@ -84,11 +89,16 @@ patchClusterFunctionsSlurm2 <- function(cf) {
8489

8590
#' ClusterFunctions for Slurm Systems (patched)
8691
#'
87-
#' This functions enhances [batchtools::makeClusterFunctionsSlurm()] by
88-
#' patching the `listJobsQueued()` cluster function such that it falls
89-
#' back to querying Slurm's account database (`sacct`), if the future was
90-
#' _not_ found in the Slurm job queue (`squeue`), which might be the case
92+
#' This functions enhances [batchtools::makeClusterFunctionsSlurm()] with
93+
#' a few patches.
94+
#' Firstly, it patches the `listJobsQueued()` cluster function such that it
95+
#' falls back to querying Slurm's account database (`sacct`), if the future
96+
#' was _not_ found in the Slurm job queue (`squeue`), which might be the case
9197
#' when Slurm provisions a job that was just submitted to the scheduler.
98+
#' Secondly, it patched the `submitJob()` cluster function such that the
99+
#' system call to `sbatch` does to capture stderr together with stdout, but
100+
#' rather separately such that any extra INFO messages from `sbatch` do
101+
#' not corrupt the output intended to come from stdout only.
92102
#'
93103
#' @inheritParams batchtools::makeClusterFunctionsSlurm
94104
#'

man/makeClusterFunctionsSlurm2.Rd

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)