Skip to content

Commit b7779d5

Browse files
Built-in templates: Add support for resources[["details"]] [#26]
1 parent 89cc2f0 commit b7779d5

21 files changed

+263
-46
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-9979
2+
Version: 0.12.2-9980
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

NEWS.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,24 @@
3333
- Add built-in template job scripts for LSF and OpenLava.
3434

3535
- All built-in template job scripts support "as-is" resource
36-
specifications via `resources[["asis"]]`.
36+
specifications via character vector `resources[["asis"]]`.
3737

3838
- All built-in template job scripts support "environment module"
39-
resource specifications via `resources[["modules"]]`. When
40-
specified, corresponding `module load <name>` entries are
41-
injected to the generated job script.
39+
resource specifications via character vector
40+
`resources[["modules"]]`. When specified, corresponding `module
41+
load <name>` entries are injected to the generated job script.
4242

4343
- All built-in template job scripts support "startup" and
44-
"shutdown" code resource specifications via
44+
"shutdown" code resource specifications via character vectors
4545
`resources[["startup"]]` and `resources[["shutdown"]]`. When
4646
specified, corresponding lines are injected in the generated job
4747
script and the beginning and end, respectively.
48-
48+
49+
- All built-in template job scripts support a "details" resource
50+
specification via logical scalar `resources[["details"]]`. If
51+
TRUE, scheduler job details are outputted to the log files at the
52+
beginning and job summaries at the end.
53+
4954
- All built-in template job scripts, which are written in Bash,
5055
error and exit early, but setting more strict Bash options. This
5156
should help with any troubleshooting, especially when getting

R/BatchtoolsFutureBackend-class.R

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,20 @@
2727
#' The default file is the one found by [batchtools::findConfFile()], if any.
2828
#'
2929
#' @param resources (optional) A named list passed to the \pkg{batchtools}
30-
#' job-script template as variable `resources`. See Section 'Resources'
31-
#' in [batchtools::submitJobs()] more details.
30+
#' job-script template as variable `resources`. This is based on how
31+
#' [batchtools::submitJobs()] works, with the exception for specially
32+
#' reserved names defined by the \pkg{future.batchtools} package;
33+
#' * `resources[["asis"]]` is a character vector that are passed as-is to
34+
#' the job script and are injected as job resource declarations.
35+
#' * `resources[["modules"]]` is character vector of Linux environment
36+
#' modules to be loaded.
37+
#' * `resources[["startup"]]` and `resources[["shutdown"]]` are character
38+
#' vectors of shell code to be injected to the job script as-is.
39+
#' * `resources[["details"]]`, if TRUE, results in the job script outputting
40+
#' job details and job summaries at the beginning and then end.
41+
#' * All remaining `resources` named elements are injected as named resource
42+
#' specification for the scheduler.
43+
#'
3244
#'
3345
#' @param delete Controls if and when the batchtools job registry folder is
3446
#' deleted.

R/batchtools_lsf.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ BatchtoolsLsfFutureBackend <- function(...) {
4141
#' # Submit to the 'freecycle' queue.
4242
#' plan(future.batchtools::batchtools_lsf, resources = list(
4343
#' W = "00:10:00", M = "400",
44-
#' asis = c("-n 4", "-R 'span[hosts=1]'", "-q freecycle")
44+
#' asis = c("-n 4", "-R 'span[hosts=1]'", "-q freecycle"),
45+
#' modules = c("r", "jags"),
46+
#' details = TRUE
4547
#' ))
4648
#'
4749
#' f <- future({

R/batchtools_openlava.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ BatchtoolsOpenLavaFutureBackend <- function(...) {
4141
#' # Submit to the 'freecycle' queue.
4242
#' plan(future.batchtools::batchtools_openlava, resources = list(
4343
#' W = "00:10:00", M = "400",
44-
#' asis = c("-n 4", "-R 'span[hosts=1]'", "-q freecycle")
44+
#' asis = c("-n 4", "-R 'span[hosts=1]'", "-q freecycle"),
45+
#' modules = c("r", "jags"),
46+
#' details = TRUE
4547
#' ))
4648
#'
4749
#' f <- future({

R/batchtools_sge.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ print.BatchtoolsSGEFutureBackend <- function(x, ...) {
5454
#' # Submit to the 'freecycle' queue.
5555
#' plan(future.batchtools::batchtools_sge, resources = list(
5656
#' h_rt = "00:10:00", mem_free = "100M", ## memory is per process
57-
#' asis = c("-pe smp 4", "-q freecycle.q")
57+
#' asis = c("-pe smp 4", "-q freecycle.q"),
58+
#' modules = c("r", "jags"),
59+
#' details = TRUE
5860
#' ))
5961
#'
6062
#' f <- future({

R/batchtools_slurm.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ print.BatchtoolsSlurmFutureBackend <- function(x, ...) {
5858
#' # Submit to the 'freecycle' partition.
5959
#' plan(future.batchtools::batchtools_slurm, resources = list(
6060
#' time = "00:10:00", mem = "400M",
61-
#' asis = c("--nodes=1", "--ntasks=4", "--partition=freecycle")
61+
#' asis = c("--nodes=1", "--ntasks=4", "--partition=freecycle"),
62+
#' modules = c("r", "jags"),
63+
#' details = TRUE
6264
#' ))
6365
#'
6466
#' f <- future({

R/batchtools_torque.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ BatchtoolsTorqueFutureBackend <- function(...) {
4040
#' # Submit to the 'freecycle' queue.
4141
#' plan(future.batchtools::batchtools_torque, resources = list(
4242
#' walltime = "00:10:00", mem = "100mb", ## memory is per process
43-
#' asis = c("-l nodes=1:ppn=4", "-q freecycle")
43+
#' asis = c("-l nodes=1:ppn=4", "-q freecycle"),
44+
#' modules = c("r", "jags"),
45+
#' details = TRUE
4446
#' ))
4547
#'
4648
#' f <- future({

inst/templates/lsf.tmpl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
job_declarations <- resources[["asis"]]
1818
resources[["asis"]] <- NULL
1919

20+
## Should scheduler "details" be seen?
21+
details <- isTRUE(resources[["details"]])
22+
resources[["details"]] <- NULL
23+
2024
## Shell "startup" code to evaluate
2125
startup <- resources[["startup"]]
2226
resources[["startup"]] <- NULL
@@ -70,11 +74,14 @@ echo "Job submission declarations:"
7074
writeLines(sprintf("echo '%s'", job_declarations))
7175
%>
7276

77+
<% if (details) { %>
7378
if command -v bjobs > /dev/null; then
7479
echo "Job information:"
7580
bjobs -l "${LSB_JOBID}"
7681
echo
7782
fi
83+
<% } %>
84+
7885

7986
## Launch R and evaluate the batchtools R job
8087
echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ..."
@@ -83,11 +90,12 @@ res=$?
8390
echo " - exit code: ${res}"
8491
echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ... done"
8592

86-
## End-of-job summary
93+
<% if (details) { %>
8794
if command -v bjobs > /dev/null; then
8895
echo "Job summary:"
8996
bjobs -l "${LSB_JOBID}"
9097
fi
98+
<% } %>
9199

92100
<% if (length(shutdown) > 0) {
93101
## Inject optional shell code

inst/templates/openlava.tmpl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
job_declarations <- resources[["asis"]]
1818
resources[["asis"]] <- NULL
1919

20+
## Should scheduler "details" be seen?
21+
details <- isTRUE(resources[["details"]])
22+
resources[["details"]] <- NULL
23+
2024
## Shell "startup" code to evaluate
2125
startup <- resources[["startup"]]
2226
resources[["startup"]] <- NULL
@@ -70,11 +74,14 @@ echo "Job submission declarations:"
7074
writeLines(sprintf("echo '%s'", job_declarations))
7175
%>
7276

77+
<% if (details) { %>
7378
if command -v bjobs > /dev/null; then
7479
echo "Job information:"
7580
bjobs -l "${LSB_JOBID}"
7681
echo
7782
fi
83+
<% } %>
84+
7885

7986
## Launch R and evaluate the batchtools R job
8087
echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ..."
@@ -83,11 +90,12 @@ res=$?
8390
echo " - exit code: ${res}"
8491
echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ... done"
8592

86-
## End-of-job summary
93+
<% if (details) { %>
8794
if command -v bjobs > /dev/null; then
8895
echo "Job summary:"
8996
bjobs -l "${LSB_JOBID}"
9097
fi
98+
<% } %>
9199

92100
<% if (length(shutdown) > 0) {
93101
## Inject optional shell code

0 commit comments

Comments
 (0)