Skip to content

Commit 4649ee3

Browse files
Export makeClusterFunctionsSlurm2()
1 parent 03485e2 commit 4649ee3

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-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-9007
2+
Version: 0.20.0-9008
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export(batchtools_torque)
5959
export(loggedError)
6060
export(loggedOutput)
6161
export(makeClusterFunctionsBash)
62+
export(makeClusterFunctionsSlurm2)
6263
importFrom(batchtools,Worker)
6364
importFrom(batchtools,assertRegistry)
6465
importFrom(batchtools,batchExport)

R/batchtools_slurm.R

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ print.BatchtoolsSlurmFutureBackend <- function(x, ...) {
2828
#'
2929
#' @details
3030
#' Batchtools slurm futures use \pkg{batchtools} cluster functions
31-
#' created by [batchtools::makeClusterFunctionsSlurm()], which are used
31+
#' created by [makeClusterFunctionsSlurm2()], which are used
3232
#' to interact with the Slurm job scheduler. This requires that Slurm
33-
#' commands `sbatch`, `squeue`, and `scancel` are available on the current
34-
#' machine.
33+
#' commands `sbatch`, `squeue`, `sacct`, and `scancel` are available on
34+
#' the current machine.
3535
#'
3636
#' The default template script `templates/slurm.tmpl` can be found in:
3737
#'
@@ -43,7 +43,7 @@ print.BatchtoolsSlurmFutureBackend <- function(x, ...) {
4343
#'
4444
#' `r paste(c("\x60\x60\x60bash", readLines("inst/templates/slurm.tmpl"), "\x60\x60\x60"), collapse = "\n")`
4545
#'
46-
#' This template and the built-in [batchtools::makeClusterFunctionsSlurm()]
46+
#' This template and the built-in [makeClusterFunctionsSlurm2()]
4747
#' have been verified to work on a few different Slurm HPC clusters;
4848
#'
4949
#' 1. Slurm 21.08.4, Rocky Linux 8, NFS global filesystem (August 2025)
@@ -265,10 +265,25 @@ patchClusterFunctionsSlurm2 <- function(cf) {
265265
} ## patchClusterFunctionsSlurm2()
266266

267267

268-
#' @importFrom batchtools makeClusterFunctionsSlurm
269268

270-
makeClusterFunctionsSlurm2 <- function(template = "slurm", array.jobs = TRUE, nodename = "localhost", scheduler.latency = 1, fs.latency = 65, ...) {
271-
cf <- makeClusterFunctionsSlurm(template = template, array.jobs = array.jobs, nodename = nodename, scheduler.latency = scheduler.latency, fs.latency =fs.latency, ...)
269+
270+
#' ClusterFunctions for Slurm Systems (robustified)
271+
#'
272+
#' This functions enhances [batchtools::makeClusterFunctionsSlurm()] by
273+
#' patching the `listJobsQueued()` cluster function such that it falls
274+
#' back to querying Slurm's account database (`sacct`), if the future was
275+
#' _not_ found in the Slurm job queue (`squeue`), which might be the case
276+
#' when Slurm provisions a job that was just submitted to the scheduler.
277+
#'
278+
#' @inheritParams batchtools::makeClusterFunctionsSlurm
279+
#'
280+
#' @return
281+
#' A [batchtools::ClusterFunctions] object.
282+
#'
283+
#' @importFrom batchtools makeClusterFunctionsSlurm
284+
#' @export
285+
makeClusterFunctionsSlurm2 <- function(template = "slurm", array.jobs = TRUE, nodename = "localhost", scheduler.latency = 1, fs.latency = 65) {
286+
cf <- makeClusterFunctionsSlurm(template = template, array.jobs = array.jobs, nodename = nodename, scheduler.latency = scheduler.latency, fs.latency =fs.latency)
272287
cf <- patchClusterFunctionsSlurm2(cf)
273288
cf
274289
}

man/batchtools_slurm.Rd

Lines changed: 4 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)