Skip to content

Commit 0e4e6da

Browse files
batchtools_slurm(): Limit 'squeue' and 'sacct' troubleshooting information to the specific Slurm job ID
1 parent b3561dd commit 0e4e6da

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
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-9002
2+
Version: 0.20.0-9004
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

R/BatchtoolsFutureBackend-class.R

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -856,23 +856,27 @@ await <- function(future, cleanup = TRUE, ...) {
856856
## SPECIAL CASE: Some Slurm users report on 'expired' jobs, although they never started.
857857
## Output more breadcrumbs to be able to narrow in on what causes this. /HB 2025-09-07
858858
if (inherits(future, "BatchtoolsSlurmFuture")) {
859-
## Get _all_ jobs of the users, including those not submitted via future.batchtools
860-
slurm_job_ids <- unique(c(
861-
reg$cluster.functions$listJobsQueued(reg),
862-
reg$cluster.functions$listJobsRunning(reg)
863-
))
864-
if (length(slurm_job_ids) > 0) {
865-
info <- sprintf("Slurm job ID: [n=%d] %s", length(slurm_job_ids), commaq(slurm_job_ids))
859+
batch_id <- reg[["status"]][["batch.id"]]
860+
if (length(batch_id) > 0) {
861+
info <- sprintf("Slurm job ID: [n=%d] %s", length(batch_id), commaq(batch_id))
866862

867-
args <- c("--noheader", "--format='job_id=%i,state=%T,submitted_on=%V,time_used=%M'", sprintf("--jobs=%s", paste(slurm_job_ids, collapse = ",")))
863+
args <- c("--noheader", "--format='job_id=%i,state=%T,submitted_on=%V,time_used=%M'", sprintf("--jobs=%s", paste(batch_id, collapse = ",")))
868864
res <- system2("squeue", args = args, stdout = TRUE, stderr = TRUE)
869-
res <- paste(res, collapse = "\n")
870-
info <- c(info, sprintf("Slurm 'squeue' job status:\n%s", res))
871-
872-
args <- c("--noheader", "--parsable2", "--allocations", "--format='JobID,State,ExitCode'", sprintf("--jobs=%s", paste(slurm_job_ids, collapse = ",")))
865+
if (length(res) == 0) {
866+
res <- "<empty>"
867+
} else {
868+
res <- paste(res, collapse = "; ") ## should only be one, but just in case ...
869+
}
870+
info <- c(info, sprintf("Slurm 'squeue' job status: %s", res))
871+
872+
args <- c("--noheader", "--parsable2", "--allocations", "--format='JobID,State,ExitCode'", sprintf("--jobs=%s", paste(batch_id, collapse = ",")))
873873
res <- system2("sacct", args = args, stdout = TRUE, stderr = TRUE)
874-
res <- paste(res, collapse = "\n")
875-
info <- c(info, sprintf("Slurm 'sacct' job status:\n%s", res))
874+
if (length(res) == 0) {
875+
res <- "<empty>"
876+
} else {
877+
res <- paste(res, collapse = "; ") ## should only be one, but just in case ...
878+
}
879+
info <- c(info, sprintf("Slurm 'sacct' job status: %s", res))
876880
} else {
877881
info <- "Slurm job ID: <not found>"
878882
info <- c(info, sprintf("Slurm job status: <unknown>"))

0 commit comments

Comments
 (0)