File: batchtools_custom.R

package info (click to toggle)
r-cran-future.batchtools 0.12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 528 kB
  • sloc: sh: 82; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,619 bytes parent folder | download | duplicates (2)
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
#' Batchtools futures for custom batchtools configuration
#'
#' @inheritParams BatchtoolsFuture
#'
#' @param conf.file (character) A batchtools configuration file as for
#' instance returned by [batchtools::findConfFile()].
#'
#' @param cluster.functions A
#' [ClusterFunctions][batchtools::ClusterFunctions] object.
#'
#' @param \ldots Additional arguments passed to [BatchtoolsFuture()].
#'
#' @return An object of class `BatchtoolsFuture`.
#'
#' @example incl/batchtools_custom.R
#'
#' @export
#' @importFrom batchtools findConfFile
#' @importFrom utils file_test
batchtools_custom <- function(expr, envir = parent.frame(), substitute = TRUE,
                              globals = TRUE,
                              label = NULL,
                              resources = list(),
                              workers = NULL,
                              conf.file = findConfFile(),
                              cluster.functions = NULL,
                              registry = list(),
                              ...) {
  if (substitute) expr <- substitute(expr)

  future <- BatchtoolsCustomFuture(
    expr = expr, envir = envir, substitute = FALSE,
    globals = globals,
    label = label,
    resources = resources,
    conf.file = conf.file,
    cluster.functions = cluster.functions,
    workers = workers,
    registry = registry,
    ...
  )

  if (!future$lazy) future <- run(future)

  invisible(future)
}
class(batchtools_custom) <- c(
  "batchtools_custom", "batchtools_multiprocess", "batchtools",
  "multiprocess", "future", "function"
)
attr(batchtools_custom, "tweakable") <- c("finalize")