Skip to content

Commit f259ad2

Browse files
Add timeout <runtime> ... to the default batchtools_bash template script
1 parent 0077adb commit f259ad2

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
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-9917
2+
Version: 0.12.2-9918
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

NEWS.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313

1414
* Canceling batchtools futures will now interrupt them by default,
1515
if the backend supports it.
16-
16+
17+
## Documentation
18+
19+
* Add `timeout <runtime> ...` to the default `batchtools_bash`
20+
template script to illustrate how to control this runtime via the
21+
backend `resources` argument.
22+
1723

1824
# Version 0.12.2 [2025-06-06]
1925

R/batchtools_bash.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ BatchtoolsBashFutureBackend <- function(...,
3838
#'
3939
#' @details
4040
#' Batchtools bash futures uses \pkg{batchtools} cluster functions
41-
#' created by [makeClusterFunctionsBash()] and requires that Bash is
42-
#' installed on the current machine.
41+
#' created by [makeClusterFunctionsBash()] and requires that `bash' is
42+
#' installed on the current machine and the `timeout` command is available.
4343
#'
4444
#' The default template script `templates/bash.tmpl` can be found in:
4545
#'
@@ -52,7 +52,8 @@ BatchtoolsBashFutureBackend <- function(...,
5252
#' `r paste(c("\x60\x60\x60bash", readLines("inst/templates/bash.tmpl"), "\x60\x60\x60"), collapse = "\n")`
5353
#'
5454
#' @examplesIf interactive()
55-
#' plan(batchtools_bash)
55+
#' # Limit runtime to 30 seconds per future
56+
#' plan(batchtools_bash, resources = list(runtime = 30))
5657
#'
5758
#' message("Main process ID: ", Sys.getpid())
5859
#'

inst/templates/bash.tmpl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,12 @@
33
# A batchtools launch script template
44
######################################################################
55

6+
## Maximum runtime?
7+
<%
8+
## The default maximum runtime is one hours
9+
runtime <- resources[["runtime"]]
10+
if (is.null(runtime)) runtime <- 3600
11+
%>
12+
613
# Launch R and evaluate the batchtools R job
7-
Rscript -e 'batchtools::doJobCollection("<%= uri %>", output = "<%= log.file %>")'
14+
timeout <%= runtime %> Rscript -e 'batchtools::doJobCollection("<%= uri %>", output = "<%= log.file %>")'

man/batchtools_bash.Rd

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