Skip to content

Commit 4a54e21

Browse files
Built-in templates: Add support 'shutdown' job-script code
1 parent 4bd641e commit 4a54e21

File tree

14 files changed

+128
-5
lines changed

14 files changed

+128
-5
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-9977
2+
Version: 0.12.2-9978
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

NEWS.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@
4040
specified, corresponding `module load <name>` entries are
4141
injected to the generated job script.
4242

43-
- All built-in template job scripts support "startup code" resource
44-
specifications via `resources[["startup"]]`. When specified,
45-
corresponding lines are injected early in the generated job
46-
script.
43+
- All built-in template job scripts support "startup" and
44+
"shutdown" code resource specifications via
45+
`resources[["startup"]]` and `resources[["shutdown"]]`. When
46+
specified, corresponding lines are injected in the generated job
47+
script and the beginning and end, respectively.
4748

4849
- All built-in template job scripts, which are written in Bash,
4950
error and exit early, but setting more strict Bash options. This

inst/templates/bash.tmpl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ trap 'echo "ERROR: future.batchtools job script failed on line $LINENO" >&2; exi
2020
startup <- resources[["startup"]]
2121
resources[["startup"]] <- NULL
2222

23+
## Shell "shutdown" code to evaluate
24+
shutdown <- resources[["shutdown"]]
25+
resources[["shutdown"]] <- NULL
26+
2327
## Environment modules specifications
2428
modules <- resources[["modules"]]
2529
resources[["modules"]] <- NULL
@@ -36,4 +40,16 @@ echo "Load environment modules:"
3640
} %>
3741

3842
# Launch R and evaluate the batchtools R job
43+
echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ..."
3944
<%= timeout %> Rscript -e 'batchtools::doJobCollection("<%= uri %>", output = "<%= log.file %>")'
45+
res=$?
46+
echo " - exit code: ${res}"
47+
echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ... done"
48+
49+
<% if (length(shutdown) > 0) {
50+
## Inject optional shell code
51+
writeLines(shutdown)
52+
} %>
53+
54+
## Relay the exit code from Rscript
55+
exit "${res}"

inst/templates/lsf.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
startup <- resources[["startup"]]
2222
resources[["startup"]] <- NULL
2323

24+
## Shell "shutdown" code to evaluate
25+
shutdown <- resources[["shutdown"]]
26+
resources[["shutdown"]] <- NULL
27+
2428
## Environment modules specifications
2529
modules <- resources[["modules"]]
2630
resources[["modules"]] <- NULL
@@ -80,5 +84,10 @@ echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ... done"
8084
## End-of-job summary
8185
bjobs -l "${LSB_JOBID}"
8286

87+
<% if (length(shutdown) > 0) {
88+
## Inject optional shell code
89+
writeLines(shutdown)
90+
} %>
91+
8392
## Relay the exit code from Rscript
8493
exit "${res}"

inst/templates/openlava.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
startup <- resources[["startup"]]
2222
resources[["startup"]] <- NULL
2323

24+
## Shell "shutdown" code to evaluate
25+
shutdown <- resources[["shutdown"]]
26+
resources[["shutdown"]] <- NULL
27+
2428
## Environment modules specifications
2529
modules <- resources[["modules"]]
2630
resources[["modules"]] <- NULL
@@ -80,5 +84,10 @@ echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ... done"
8084
## End-of-job summary
8185
bjobs -l "${LSB_JOBID}"
8286

87+
<% if (length(shutdown) > 0) {
88+
## Inject optional shell code
89+
writeLines(shutdown)
90+
} %>
91+
8392
## Relay the exit code from Rscript
8493
exit "${res}"

inst/templates/sge.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
startup <- resources[["startup"]]
3131
resources[["startup"]] <- NULL
3232

33+
## Shell "shutdown" code to evaluate
34+
shutdown <- resources[["shutdown"]]
35+
resources[["shutdown"]] <- NULL
36+
3337
## Environment modules specifications
3438
modules <- resources[["modules"]]
3539
resources[["modules"]] <- NULL
@@ -89,5 +93,10 @@ echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ... done"
8993
## End-of-job summary
9094
qstat -j "${JOB_ID}"
9195

96+
<% if (length(shutdown) > 0) {
97+
## Inject optional shell code
98+
writeLines(shutdown)
99+
} %>
100+
92101
## Relay the exit code from Rscript
93102
exit "${res}"

inst/templates/slurm.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
startup <- resources[["startup"]]
2121
resources[["startup"]] <- NULL
2222

23+
## Shell "shutdown" code to evaluate
24+
shutdown <- resources[["shutdown"]]
25+
resources[["shutdown"]] <- NULL
26+
2327
## Environment modules specifications
2428
modules <- resources[["modules"]]
2529
resources[["modules"]] <- NULL
@@ -79,5 +83,10 @@ echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ... done"
7983
## End-of-job summary
8084
sstat --format="JobID,AveCPU,MaxRSS,MaxPages,MaxDiskRead,MaxDiskWrite" --allsteps --jobs="${SLURM_JOB_ID}"
8185

86+
<% if (length(shutdown) > 0) {
87+
## Inject optional shell code
88+
writeLines(shutdown)
89+
} %>
90+
8291
## Relay the exit code from Rscript
8392
exit "${res}"

inst/templates/torque.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
startup <- resources[["startup"]]
2525
resources[["startup"]] <- NULL
2626

27+
## Shell "shutdown" code to evaluate
28+
shutdown <- resources[["shutdown"]]
29+
resources[["shutdown"]] <- NULL
30+
2731
## Environment modules specifications
2832
modules <- resources[["modules"]]
2933
resources[["modules"]] <- NULL
@@ -83,5 +87,10 @@ echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ... done"
8387
## End-of-job summary
8488
qstat -f "${PBS_JOBID}"
8589

90+
<% if (length(shutdown) > 0) {
91+
## Inject optional shell code
92+
writeLines(shutdown)
93+
} %>
94+
8695
## Relay the exit code from Rscript
8796
exit "${res}"

man/batchtools_bash.Rd

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/batchtools_lsf.Rd

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)