-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbatchtools_lsf.R
More file actions
82 lines (80 loc) · 2.98 KB
/
batchtools_lsf.R
File metadata and controls
82 lines (80 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#' @export
BatchtoolsLsfFutureBackend <- function(...) {
core <- BatchtoolsTemplateFutureBackend(..., type = "lsf")
core[["futureClasses"]] <- c("BatchtoolsLsfFuture", core[["futureClasses"]])
core <- structure(core, class = c("BatchtoolsLsfFutureBackend", class(core)))
core
}
#' A batchtools LSF backend resolves futures in parallel via a Load Sharing Facility (LSF) job scheduler
#'
#' @inheritParams BatchtoolsTemplateFutureBackend
#'
#' @param template (optional) Name of job-script template to be searched
#' for by [batchtools::findTemplateFile()]. If not found, it defaults to
#' the `templates/lsf.tmpl` part of this package (see below).
#'
#' @param \ldots Not used.
#'
#' @details
#' Batchtools Load Sharing Facility (LSF) futures use \pkg{batchtools}
#' cluster functions created by [batchtools::makeClusterFunctionsLSF()],
#' which are used to interact with the LSF job scheduler. This requires
#' that LSF commands `bsub`, `bjobs`, and `bkill` are available on the
#' current machine.
#'
#' The default template script `templates/lsf.tmpl` can be found in:
#'
#' ```r
#' system.file("templates", "lsf.tmpl", package = "future.batchtools")
#' ```
#'
#' and comprise:
#'
#' `r paste(c("\x60\x60\x60bash", readLines("inst/templates/lsf.tmpl"), "\x60\x60\x60"), collapse = "\n")`
#'
#' @examplesIf interactive()
#' library(future)
#'
#' # Limit runtime to 10 minutes and total memory to 400 MiB per future,
#' # request a parallel environment with four slots on a single host.
#' # Submit to the 'freecycle' queue. Load environment modules 'r' and
#' # 'jags'. Report on job details at startup and at the end of the job.
#' plan(future.batchtools::batchtools_lsf, resources = list(
#' W = "00:10:00", M = "400",
#' asis = c("-n 4", "-R 'span[hosts=1]'", "-q freecycle"),
#' modules = c("r", "jags"),
#' details = TRUE
#' ))
#'
#' f <- future({
#' data.frame(
#' hostname = Sys.info()[["nodename"]],
#' os = Sys.info()[["sysname"]],
#' osVersion = if (is.null(utils::osVersion)) NA else utils::osVersion,
#' cores = unname(parallelly::availableCores()),
#' modules = Sys.getenv("LOADEDMODULES")
#' )
#' })
#' info <- value(f)
#' print(info)
#'
#' @references
#' * <https://en.wikipedia.org/wiki/IBM_Spectrum_LSF>
#'
#' @export
batchtools_lsf <- function(..., template = "lsf", scheduler.latency = 1.0, fs.latency = 65.0, resources = list(), delete = getOption("future.batchtools.delete", "on-success"), workers = getOption("future.batchtools.workers", default = 100L)) {
stop("INTERNAL ERROR: The future.batchtools::batchtools_lsf() must never be called directly")
}
class(batchtools_lsf) <- c(
"batchtools_lsf", "batchtools_template",
"batchtools_multiprocess", "batchtools",
"multiprocess", "future", "function"
)
attr(batchtools_lsf, "tweakable") <- c(
"workers",
"finalize",
## Arguments to batchtools::makeClusterFunctionsLSF()
"scheduler.latency", "fs.latency"
)
attr(batchtools_lsf, "init") <- TRUE
attr(batchtools_lsf, "factory") <- BatchtoolsLsfFutureBackend