Skip to content

Commit aedf289

Browse files
Now all built-in template job scripts supports as-is resource specifications via resources[["asis"]]
1 parent 93395f2 commit aedf289

File tree

12 files changed

+109
-38
lines changed

12 files changed

+109
-38
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-9945
2+
Version: 0.12.2-9946
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

NEWS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
* Tidy up built-in template job script for Bash, SGE, Slurm and
1818
Torque/PBS.
1919

20-
* Add built-in template job script for LSF and OpenLava.
20+
* Add built-in template job scripts for LSF and OpenLava.
21+
22+
* Now all built-in template job scripts supports as-is resource
23+
specifications via `resources[["asis"]]`.
2124

2225
## Documentation
2326

inst/templates/lsf.tmpl

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

1414
## Resources needed:
1515
<% if (length(resources) > 0) {
16+
prefix <- "#BSUB "
17+
18+
## As-is resource specifications
19+
if ("asis" %in% names(resources)) {
20+
writeLines(sprintf("%s%s", prefix, resources[["asis"]]))
21+
resources <- resources[names(resources) != "asis"]
22+
}
23+
24+
## Remaining resources are assumed to be of type '-<key>=<value>'
1625
opts <- unlist(resources, use.names = TRUE)
1726
opts <- sprintf("-%s=%s", names(opts), opts)
18-
writeLines(sprintf("#BSUB %s", opts))
27+
writeLines(sprintf("%s%s", prefix, opts))
1928
} %>
2029

2130
echo "Batchtools information:"

inst/templates/openlava.tmpl

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

1414
## Resources needed:
1515
<% if (length(resources) > 0) {
16+
prefix <- "#BSUB "
17+
18+
## As-is resource specifications
19+
if ("asis" %in% names(resources)) {
20+
writeLines(sprintf("%s%s", prefix, resources[["asis"]]))
21+
resources <- resources[names(resources) != "asis"]
22+
}
23+
24+
## Remaining resources are assumed to be of type '-<key>=<value>'
1625
opts <- unlist(resources, use.names = TRUE)
1726
opts <- sprintf("-%s=%s", names(opts), opts)
18-
writeLines(sprintf("#BSUB %s", opts))
27+
writeLines(sprintf("%s%s", prefix, opts))
1928
} %>
2029

2130
echo "Batchtools information:"

inst/templates/sge.tmpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,21 @@
2525

2626
## Resources needed:
2727
<% if (length(resources) > 0) {
28+
prefix <- "#$ "
29+
2830
## As-is resource specifications, e.g.
2931
## sge_options <- c("-pe smp 2", "-R yes")
3032
## plan(batchtools_sge, resources = list(asis = sge_options))
3133
if ("asis" %in% names(resources)) {
32-
cat(sprintf("#$ %s\n", resources[["asis"]]))
34+
writeLines(sprintf("%s%s", prefix, resources[["asis"]]))
3335
resources <- resources[names(resources) != "asis"]
3436
}
3537

36-
## Remaining resources are assumed to be of type '-l', e.g.
38+
## Remaining resources are assumed to be of type '-l <key>=<value>', e.g.
3739
## plan(batchtools_sge, resources = list(mem_free = "1G", h_rt="00:20:00"))
3840
opts <- unlist(resources, use.names = TRUE)
3941
opts <- sprintf("-l %s=%s", names(opts), opts)
40-
writeLines(sprintf("#$ %s", opts))
42+
writeLines(sprintf("%s%s", prefix, opts))
4143
} %>
4244

4345
echo "Batchtools information:"

inst/templates/slurm.tmpl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@
88

99
#SBATCH --job-name=<%= job.name %>
1010
#SBATCH --output=<%= log.file %>
11-
<%
12-
defaults <- list(
13-
nodes = 1, # single-host processing
14-
time = "00:05:00", # 5-min runtime
15-
mem = "100M" # 100 MiB memory
16-
)
17-
resources <- c(resources, defaults[setdiff(names(defaults), names(resources))])
18-
opts <- unlist(resources, use.names = TRUE)
19-
opts <- sprintf("--%s=%s", names(opts), opts)
20-
writeLines(sprintf("#SBATCH %s", opts))
21-
%>
11+
12+
## Resources needed:
13+
<% if (length(resources) > 0) {
14+
prefix <- "#SBATCH "
15+
16+
## As-is resource specifications
17+
if ("asis" %in% names(resources)) {
18+
writeLines(sprintf("%s%s", prefix, resources[["asis"]]))
19+
resources <- resources[names(resources) != "asis"]
20+
}
21+
22+
## Remaining resources are assumed to be of type '--<key>=<value>'
23+
opts <- unlist(resources, use.names = TRUE)
24+
opts <- sprintf("--%s=%s", names(opts), opts)
25+
writeLines(sprintf("%s%s", prefix, opts))
26+
} %>
2227

2328
echo "Batchtools information:"
2429
echo "- job name: '<%= job.name %>'"

inst/templates/torque.tmpl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,18 @@
1919

2020
## Resources needed:
2121
<% if (length(resources) > 0) {
22+
prefix <- "#PBS "
23+
24+
## As-is resource specifications
25+
if ("asis" %in% names(resources)) {
26+
writeLines(sprintf("%s%s", prefix, resources[["asis"]]))
27+
resources <- resources[names(resources) != "asis"]
28+
}
29+
30+
## Remaining resources are assumed to be of type '-l <key>=<value>'
2231
opts <- unlist(resources, use.names = TRUE)
23-
opts <- sprintf("%s=%s", names(opts), opts)
24-
writeLines(sprintf("#PBS -l %s", opts))
32+
opts <- sprintf("-l %s=%s", names(opts), opts)
33+
writeLines(sprintf("%s%s", prefix, opts))
2534
} %>
2635

2736
echo "Batchtools information:"

man/batchtools_lsf.Rd

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/batchtools_openlava.Rd

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/batchtools_sge.Rd

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

0 commit comments

Comments
 (0)