Skip to content

Commit d2a3f78

Browse files
committed
Enable progress bars in non-interactive mode for SLURM clusters
Configure pbapply to display text-based progress bars when running in non-interactive mode (e.g., batch jobs, Rscript). Previously, progress tracking was disabled in non-interactive sessions, making it impossible to monitor simulation progress in SLURM log files. Changes: - R/analysis.R: Add pboptions configuration to force type="txt" in non-interactive mode while preserving timer bars in interactive sessions - R/runSimulation.R: Update progress parameter documentation to describe the new behavior Interactive users see no change. Non-interactive users (SLURM, batch jobs) now see text progress bars when monitoring logs via tail -f. Fixes #75
1 parent 4b23b45 commit d2a3f78

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

R/analysis.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ Analysis <- function(Functions, condition, replications, fixed_objects, cl, MPI,
1010
{
1111
# This defines the work-flow for the Monte Carlo simulation given the condition (row in Design)
1212
# and number of replications desired
13+
14+
# Configure pbapply for non-interactive mode (e.g., SLURM cluster logs)
15+
if(progress && !interactive()) {
16+
old_pboptions <- pbapply::pboptions(type = "txt", char = "=", style = 3)
17+
on.exit(pbapply::pboptions(old_pboptions), add = TRUE)
18+
}
19+
1320
used_mainsim <- if(is.finite(max_time)) mainsim_maxtime else mainsim
1421
if(useFuture){
1522
if(!is.null(seed)) set_seed(seed[condition$ID])

R/runSimulation.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,9 @@
600600
#' range 1 to 2147483647 for each condition via \code{\link{genSeeds}}
601601
#'
602602
#' @param progress logical; display a progress bar (using the \code{pbapply} package)
603-
#' for each simulation condition?
603+
#' for each simulation condition? In interactive sessions, shows a timer-based
604+
#' progress bar. In non-interactive sessions (e.g., HPC cluster jobs), displays
605+
#' text-based progress updates that are visible in log files.
604606
#' This is useful when simulations conditions take a long time to run (see also the
605607
#' \code{notification} argument). Default is \code{TRUE}
606608
#'

0 commit comments

Comments
 (0)