Skip to content

Commit 21bc960

Browse files
CLEANUP: batchtools (>= 0.9.10) exports findTemplateFile()
1 parent 74b36c6 commit 21bc960

File tree

4 files changed

+18
-25
lines changed

4 files changed

+18
-25
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Depends:
44
R (>= 3.2.0),
55
future (>= 1.12.0)
66
Imports:
7-
batchtools (>= 0.9.8)
7+
batchtools (>= 0.9.11)
88
Suggests:
99
future.apply,
1010
listenv,

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export(status)
3030
importFrom(batchtools,batchExport)
3131
importFrom(batchtools,batchMap)
3232
importFrom(batchtools,clearRegistry)
33+
importFrom(batchtools,findTemplateFile)
3334
importFrom(batchtools,getErrorMessages)
3435
importFrom(batchtools,getLog)
3536
importFrom(batchtools,getStatus)

R/batchtools_template.R

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class(batchtools_torque) <- c("batchtools_torque", "batchtools_template",
118118
"batchtools", "multiprocess", "future",
119119
"function")
120120

121-
121+
#' @importFrom batchtools findTemplateFile
122122
#' @importFrom batchtools makeClusterFunctionsLSF
123123
#' @importFrom batchtools makeClusterFunctionsOpenLava
124124
#' @importFrom batchtools makeClusterFunctionsSGE
@@ -152,28 +152,24 @@ batchtools_by_template <- function(expr, envir = parent.frame(),
152152
!is.na(template), nzchar(template))
153153

154154
## Tweaked search for template file
155-
findTemplateFile <- import_batchtools("findTemplateFile", default = NA)
156-
if (!identical(findTemplateFile, NA)) {
157-
pathname <- tryCatch({
158-
findTemplateFile(template)
159-
}, error = function(ex) {
160-
## Try to find it in this package?
161-
if (grepl("Argument 'template'", conditionMessage(ex))) {
162-
pathname <- system.file("templates", sprintf("%s.tmpl", template),
163-
package = "future.batchtools")
164-
if (file_test("-f", pathname)) return(pathname)
165-
}
166-
stop(ex)
167-
})
168-
169-
if (is.na(pathname)) {
170-
stop(sprintf("Failed to locate a batchtools template file: *%s.tmpl",
171-
template))
155+
pathname <- tryCatch({
156+
findTemplateFile(template)
157+
}, error = function(ex) {
158+
## Try to find it in this package?
159+
if (grepl("Argument 'template'", conditionMessage(ex))) {
160+
pathname <- system.file("templates", sprintf("%s.tmpl", template),
161+
package = "future.batchtools")
162+
if (file_test("-f", pathname)) return(pathname)
172163
}
173-
174-
template <- pathname
164+
stop(ex)
165+
})
166+
if (is.na(pathname)) {
167+
stop(sprintf("Failed to locate a batchtools template file: *%s.tmpl",
168+
template))
175169
}
176170

171+
template <- pathname
172+
177173
cluster.functions <- make_cfs(template)
178174
attr(cluster.functions, "template") <- template
179175

R/utils.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,6 @@ import_future <- function(name, default = NULL) {
134134
import_from(name, default = default, package = "future")
135135
}
136136

137-
import_batchtools <- function(name, default = NULL) {
138-
import_from(name, default = default, package = "batchtools")
139-
}
140-
141137
## Evaluates an expression in global environment.
142138
## Because geval() is exported, we want to keep its environment()
143139
## as small as possible, which is why we use local(). Without,

0 commit comments

Comments
 (0)