Skip to content

Commit 31487d6

Browse files
Make BatchtoolsBashFutureBackend inherit from BatchtoolsTemplateFutureBackend. The purpose of this backend is mainly to serve as an example how to write a new templated backend
1 parent 20da1b8 commit 31487d6

11 files changed

+60
-73
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-9951
2+
Version: 0.12.2-9952
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

R/BatchtoolsTemplateFutureBackend-class.R

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@
4747
#' @importFrom batchtools makeClusterFunctionsSlurm
4848
#' @importFrom batchtools makeClusterFunctionsTORQUE
4949
#' @export
50-
BatchtoolsTemplateFutureBackend <- function(type = c("lsf", "openlava", "sge", "slurm", "torque"), scheduler.latency = 1.0, fs.latency = 65.0, template = NULL, workers = getOption("future.batchtools.workers", default = 100L), ...) {
50+
BatchtoolsTemplateFutureBackend <- function(type, scheduler.latency = 1.0, fs.latency = 65.0, resources = list(), template = NULL, makeClusterFunctions = NULL, workers = getOption("future.batchtools.workers", default = 100L), ...) {
5151
assert_no_positional_args_but_first()
52-
type <- match.arg(type)
53-
52+
stop_if_not(
53+
is.character(type),
54+
length(type) == 1,
55+
!is.na(type),
56+
nzchar(type)
57+
)
58+
5459
if (is.function(workers)) workers <- workers()
5560
stop_if_not(
5661
is.numeric(workers),
@@ -67,9 +72,15 @@ BatchtoolsTemplateFutureBackend <- function(type = c("lsf", "openlava", "sge", "
6772
openlava = makeClusterFunctionsOpenLava,
6873
sge = makeClusterFunctionsSGE,
6974
slurm = makeClusterFunctionsSlurm,
70-
torque = makeClusterFunctionsTORQUE
75+
torque = makeClusterFunctionsTORQUE,
76+
makeClusterFunctions
7177
)
72-
78+
if (is.null(make_cfs)) {
79+
stop("Argument 'makeClusterFunctions' is not specified")
80+
} else if (!is.function(make_cfs)) {
81+
stop("Argument 'makeClusterFunctions' should be a function: ", mode(make_cfs))
82+
}
83+
7384
make_cfs_formals <- formals(make_cfs)
7485

7586
## Get the default template?

R/batchtools_bash.R

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
#' @inheritParams BatchtoolsTemplateFutureBackend
22
#' @inheritParams batchtools::makeClusterFunctions
33
#'
4-
#' @rdname BatchtoolsFutureBackend
54
#' @keywords internal
65
#'
76
#' @export
8-
BatchtoolsBashFutureBackend <- function(...,
9-
cluster.functions = makeClusterFunctionsBash(template = template, fs.latency = fs.latency),
10-
fs.latency = 0.0,
11-
template = "bash") {
7+
BatchtoolsBashFutureBackend <- function(..., template = "bash", fs.latency = 0.0) {
128
assert_no_positional_args_but_first()
139

1410
args <- list(...)
1511
if ("workers" %in% names(args)) {
1612
stop("Unknown argument 'workers'")
1713
}
1814

19-
core <- BatchtoolsUniprocessFutureBackend(
15+
core <- BatchtoolsTemplateFutureBackend(
2016
...,
21-
cluster.functions = cluster.functions,
22-
template = template
17+
template = template,
18+
workers = 1L,
19+
type = "bash",
20+
makeClusterFunctions = makeClusterFunctionsBash
2321
)
2422

2523
core[["futureClasses"]] <- c("BatchtoolsBashFuture", core[["futureClasses"]])
@@ -34,9 +32,7 @@ BatchtoolsBashFutureBackend <- function(...,
3432
#' custom \pkg{future.batchtools} backend that uses a templated job script.
3533
#' Please see the source code, for details.
3634
#'
37-
#' @inheritParams BatchtoolsFutureBackend
3835
#' @inheritParams BatchtoolsTemplateFutureBackend
39-
#' @inheritParams BatchtoolsBashFutureBackend
4036
#'
4137
#' @param template (optional) Name of job-script template to be searched
4238
#' for by [batchtools::findTemplateFile()]. If not found, it defaults to
@@ -72,15 +68,7 @@ BatchtoolsBashFutureBackend <- function(...,
7268
#' message("Worker process ID: ", pid)
7369
#'
7470
#' @export
75-
batchtools_bash <- function(
76-
...,
77-
cluster.functions = makeClusterFunctionsBash(template = "bash", fs.latency = 0.0),
78-
fs.latency = 0.0,
79-
template = "bash",
80-
registry = list(),
81-
conf.file = findConfFile(),
82-
resources = list(),
83-
finalize = getOption("future.finalize", TRUE)) {
71+
batchtools_bash <- function(..., template = "bash", fs.latency = 0.0, resources = list()) {
8472
stop("INTERNAL ERROR: The future.batchtools::batchtools_bash() must never be called directly")
8573
}
8674
class(batchtools_bash) <- c(
@@ -105,7 +93,7 @@ attr(batchtools_bash, "factory") <- BatchtoolsBashFutureBackend
10593
#' @importFrom batchtools cfReadBrewTemplate cfBrewTemplate makeClusterFunctions makeSubmitJobResult
10694
#' @importFrom utils file_test
10795
#' @export
108-
makeClusterFunctionsBash <- function(template = "bash", fs.latency = 0.0) {
96+
makeClusterFunctionsBash <- function(template = "bash", fs.latency = 0.0, ...) {
10997
bin <- Sys.which("bash")
11098
stop_if_not(file_test("-f", bin), file_test("-x", bin))
11199

man/BatchtoolsFutureBackend.Rd

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

man/BatchtoolsTemplateFutureBackend.Rd

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

man/batchtools_bash.Rd

Lines changed: 5 additions & 31 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: 4 additions & 0 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: 4 additions & 0 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: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/batchtools_slurm.Rd

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