Skip to content

Commit 7479814

Browse files
Simplify templates
1 parent eb1e0c5 commit 7479814

File tree

12 files changed

+81
-69
lines changed

12 files changed

+81
-69
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-9947
2+
Version: 0.12.2-9948
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

R/batchtools_sge.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ BatchtoolsSGEFutureBackend <- function(...) {
4040
#' @examplesIf interactive()
4141
#' library(future)
4242
#'
43-
#' # Limit runtime to 3 minutes and memory to 200 MiB per future
44-
#' plan(future.batchtools::batchtools_sge, resources = list(h_rt = "00:03:00", mem_free = "200M"))
43+
#' # Limit runtime to 3 minutes and memory to 200 MiB per future,
44+
#' # request two slots and run in the current working directory.
45+
#' plan(future.batchtools::batchtools_sge, resources = list(
46+
#' h_rt = "00:03:00", mem_free = "200M",
47+
#' asis = c("-pe smp 2", "-cwd")
48+
#' ))
4549
#'
4650
#' f <- future(Sys.info())
4751
#' info <- value(f)

inst/templates/lsf.tmpl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@
1313

1414
## Resources needed:
1515
<% if (length(resources) > 0) {
16-
prefix <- "#BSUB "
17-
1816
## As-is resource specifications
1917
if ("asis" %in% names(resources)) {
20-
writeLines(sprintf("%s%s", prefix, resources[["asis"]]))
18+
lines <- resources[["asis"]]
2119
resources <- resources[names(resources) != "asis"]
20+
} else {
21+
lines <- character(0)
2222
}
2323

2424
## Remaining resources are assumed to be of type '-<key>=<value>'
2525
opts <- unlist(resources, use.names = TRUE)
2626
opts <- sprintf("-%s=%s", names(opts), opts)
27-
writeLines(sprintf("%s%s", prefix, opts))
27+
lines <- sprintf("#BSUB %s", c(lines, opts))
28+
writeLines(lines)
2829
} %>
2930

3031
echo "Batchtools information:"
@@ -42,7 +43,7 @@ echo
4243

4344
echo "Job submission declarations:"
4445
<%
45-
writeLines(sprintf("echo '#BSUB %s'", opts))
46+
writeLines(sprintf("echo '%s'", lines))
4647
%>
4748

4849
echo "Job information:"

inst/templates/openlava.tmpl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@
1313

1414
## Resources needed:
1515
<% if (length(resources) > 0) {
16-
prefix <- "#BSUB "
17-
1816
## As-is resource specifications
1917
if ("asis" %in% names(resources)) {
20-
writeLines(sprintf("%s%s", prefix, resources[["asis"]]))
18+
lines <- resources[["asis"]]
2119
resources <- resources[names(resources) != "asis"]
20+
} else {
21+
lines <- character(0)
2222
}
2323

2424
## Remaining resources are assumed to be of type '-<key>=<value>'
2525
opts <- unlist(resources, use.names = TRUE)
2626
opts <- sprintf("-%s=%s", names(opts), opts)
27-
writeLines(sprintf("%s%s", prefix, opts))
27+
lines <- sprintf("#BSUB %s", c(lines, opts))
28+
writeLines(lines)
2829
} %>
2930

3031
echo "Batchtools information:"
@@ -42,7 +43,7 @@ echo
4243

4344
echo "Job submission declarations:"
4445
<%
45-
writeLines(sprintf("echo '#BSUB %s'", opts))
46+
writeLines(sprintf("echo '%s'", lines))
4647
%>
4748

4849
echo "Job information:"

inst/templates/sge.tmpl

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

2626
## Resources needed:
2727
<% if (length(resources) > 0) {
28-
prefix <- "#$ "
29-
30-
## As-is resource specifications, e.g.
31-
## sge_options <- c("-pe smp 2", "-R yes")
32-
## plan(batchtools_sge, resources = list(asis = sge_options))
28+
## As-is resource specifications
3329
if ("asis" %in% names(resources)) {
34-
writeLines(sprintf("%s%s", prefix, resources[["asis"]]))
30+
lines <- resources[["asis"]]
3531
resources <- resources[names(resources) != "asis"]
32+
} else {
33+
lines <- character(0)
3634
}
37-
38-
## Remaining resources are assumed to be of type '-l <key>=<value>', e.g.
39-
## plan(batchtools_sge, resources = list(mem_free = "1G", h_rt="00:20:00"))
35+
36+
## Remaining resources are assumed to be of type '-l <key>=<value>'
4037
opts <- unlist(resources, use.names = TRUE)
4138
opts <- sprintf("-l %s=%s", names(opts), opts)
42-
writeLines(sprintf("%s%s", prefix, opts))
39+
lines <- sprintf("#$ %s", c(lines, opts))
40+
writeLines(lines)
4341
} %>
4442

4543
echo "Batchtools information:"
@@ -57,7 +55,7 @@ echo
5755

5856
echo "Job submission declarations:"
5957
<%
60-
writeLines(sprintf("echo '#$ %s'", opts))
58+
writeLines(sprintf("echo '%s'", lines))
6159
%>
6260

6361
echo "Job information:"

inst/templates/slurm.tmpl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@
1111

1212
## Resources needed:
1313
<% if (length(resources) > 0) {
14-
prefix <- "#SBATCH "
15-
1614
## As-is resource specifications
1715
if ("asis" %in% names(resources)) {
18-
writeLines(sprintf("%s%s", prefix, resources[["asis"]]))
16+
lines <- resources[["asis"]]
1917
resources <- resources[names(resources) != "asis"]
18+
} else {
19+
lines <- character(0)
2020
}
21-
21+
2222
## Remaining resources are assumed to be of type '--<key>=<value>'
2323
opts <- unlist(resources, use.names = TRUE)
2424
opts <- sprintf("--%s=%s", names(opts), opts)
25-
writeLines(sprintf("%s%s", prefix, opts))
25+
lines <- sprintf("#SBATCH %s", c(lines, opts))
26+
writeLines(lines)
2627
} %>
2728

2829
echo "Batchtools information:"
@@ -40,7 +41,7 @@ echo
4041

4142
echo "Job submission declarations:"
4243
<%
43-
writeLines(sprintf("echo '#SBATCH %s'", opts))
44+
writeLines(sprintf("echo '%s'", lines))
4445
%>
4546

4647
echo "Slurm job information:"

inst/templates/torque.tmpl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@
1919

2020
## Resources needed:
2121
<% if (length(resources) > 0) {
22-
prefix <- "#PBS "
23-
2422
## As-is resource specifications
2523
if ("asis" %in% names(resources)) {
26-
writeLines(sprintf("%s%s", prefix, resources[["asis"]]))
24+
lines <- resources[["asis"]]
2725
resources <- resources[names(resources) != "asis"]
26+
} else {
27+
lines <- character(0)
2828
}
2929

3030
## Remaining resources are assumed to be of type '-l <key>=<value>'
3131
opts <- unlist(resources, use.names = TRUE)
3232
opts <- sprintf("-l %s=%s", names(opts), opts)
33-
writeLines(sprintf("%s%s", prefix, opts))
33+
lines <- sprintf("#PBS %s", c(lines, opts))
34+
writeLines(lines)
3435
} %>
3536

3637
echo "Batchtools information:"
@@ -48,7 +49,7 @@ echo
4849

4950
echo "Job submission declarations:"
5051
<%
51-
writeLines(sprintf("echo '#PBS -l %s'", opts))
52+
writeLines(sprintf("echo '%s'", lines))
5253
%>
5354

5455
echo "Job information:"

man/batchtools_lsf.Rd

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

man/batchtools_openlava.Rd

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

man/batchtools_sge.Rd

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

0 commit comments

Comments
 (0)