Skip to content

Commit 64c6206

Browse files
committed
Merge branch 'master' of github.com:mllg/batchtools
2 parents 03294c2 + cd5f34d commit 64c6206

File tree

125 files changed

+3055
-1670
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+3055
-1670
lines changed

.aspell/batchtools.rds

65 Bytes
Binary file not shown.

.aspell/defaults.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Rd_files <- vignettes <- R_files <- description <-
2+
list(encoding = "UTF-8", language = "en", dictionaries = c("en_stats", "batchtools"))

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: batchtools
22
Title: Tools for Computation on Batch Systems
3-
Version: 0.9.9
3+
Version: 0.9.10-9000
44
Authors@R: c(
55
person("Michel", "Lang", NULL, "[email protected]",
66
role = c("cre", "aut"), comment = c(ORCID = "0000-0001-9754-0393")),
@@ -35,7 +35,7 @@ Imports:
3535
brew,
3636
checkmate (>= 1.8.5),
3737
digest (>= 0.6.9),
38-
fs (>= 1.1.0),
38+
fs (>= 1.2.0),
3939
parallel,
4040
progress (>= 1.1.1),
4141
R6,
@@ -50,6 +50,7 @@ Suggests:
5050
doMPI,
5151
e1071,
5252
foreach,
53+
future,
5354
future.batchtools,
5455
knitr,
5556
parallelMap,

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ export(cfHandleUnknownSubmitError)
4040
export(cfKillJob)
4141
export(cfReadBrewTemplate)
4242
export(chunk)
43-
export(chunkIds)
4443
export(clearRegistry)
4544
export(doJobCollection)
4645
export(estimateRuntimes)
4746
export(execJob)
47+
export(findConfFile)
4848
export(findDone)
4949
export(findErrors)
5050
export(findExperiments)
@@ -59,6 +59,7 @@ export(findRunning)
5959
export(findStarted)
6060
export(findSubmitted)
6161
export(findTagged)
62+
export(findTemplateFile)
6263
export(flatten)
6364
export(getDefaultRegistry)
6465
export(getErrorMessages)

NEWS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# batchtools 0.9.11
2+
3+
* Removed deprecated function `chunkIds()`.
4+
5+
# batchtools 0.9.10
6+
7+
* Exported functions `findConfFile()` and `findTemplateFile()`.
8+
* Dropped support for providing a template file directly as string. A valid file is now always required.
9+
* Fixed writing to `TMPDIR` instead of the R session's temporary directory.
10+
111
# batchtools 0.9.9
212

313
* RDS files are explicitly stored in version 2 to ensure backward compatibility with R versions prior to 3.5.0.

R/Registry.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@
5555
#' In the configuration file you can define how \pkg{batchtools} interacts with the system via \code{\link{ClusterFunctions}}.
5656
#' Separating the configuration of the underlying host system from the R code allows to easily move computation to another site.
5757
#'
58-
#' The file lookup is implemented in the internal function \code{findConfFile} which returns the first file found of the following candidates:
58+
#' The file lookup is implemented in the internal (but exported) function \code{findConfFile} which returns the first file found of the following candidates:
5959
#' \enumerate{
6060
#' \item{File \dQuote{batchtools.conf.R} in the path specified by the environment variable \dQuote{R_BATCHTOOLS_SEARCH_PATH}.}
6161
#' \item{File \dQuote{batchtools.conf.R} in the current working directory.}
6262
#' \item{File \dQuote{config.R} in the user configuration directory as reported by \code{rappdirs::user_config_dir("batchtools", expand = FALSE)} (depending on OS, e.g., on linux this usually resolves to \dQuote{~/.config/batchtools/config.R}).}
6363
#' \item{\dQuote{.batchtools.conf.R} in the home directory (\dQuote{~}).}
6464
#' \item{\dQuote{config.R} in the site config directory as reported by \code{rappdirs::site_config_dir("batchtools")} (depending on OS). This file can be used for admins to set sane defaults for a computation site.}
6565
#' }
66-
#' Set to \code{character(0)} if you want to suppress reading any configuration file.
66+
#' Set to \code{NA} if you want to suppress reading any configuration file.
6767
#' If a configuration file is found, it gets sourced inside the environment of the registry after the defaults for all variables are set.
6868
#' Therefore you can set and overwrite slots, e.g. \code{default.resources = list(walltime = 3600)} to set default resources or \dQuote{max.concurrent.jobs} to
6969
#' limit the number of jobs allowed to run simultaneously on the system.
@@ -128,7 +128,7 @@ makeRegistry = function(file.dir = "registry", work.dir = getwd(), conf.file = f
128128
assertPathForOutput(file.dir, overwrite = FALSE)
129129
assertString(work.dir)
130130
assertDirectoryExists(work.dir, access = "r")
131-
assertCharacter(conf.file, any.missing = FALSE, max.len = 1L)
131+
assertString(conf.file, na.ok = TRUE)
132132
assertCharacter(packages, any.missing = FALSE, min.chars = 1L)
133133
assertCharacter(namespaces, any.missing = FALSE, min.chars = 1L)
134134
assertCharacter(source, any.missing = FALSE, min.chars = 1L)
@@ -185,8 +185,8 @@ makeRegistry = function(file.dir = "registry", work.dir = getwd(), conf.file = f
185185
"!DEBUG [makeRegistry]: Creating directories in '`reg$file.dir`'"
186186

187187
fs::dir_create(c(reg$file.dir, reg$work.dir))
188-
reg$file.dir = path_real(reg$file.dir)
189-
reg$work.dir = path_real(reg$work.dir)
188+
reg$file.dir = fs::path_abs(reg$file.dir)
189+
reg$work.dir = fs::path_abs(reg$work.dir)
190190

191191
fs::dir_create(fs::path(reg$file.dir, c("jobs", "results", "updates", "logs", "exports", "external")))
192192
with_dir(reg$work.dir, loadRegistryDependencies(reg))

R/chunkIds.R

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,8 @@
1-
#' @title Chunk Jobs for Sequential Execution
2-
#'
3-
#' @description
4-
#' This function is deprecated in favor of the more flexible \code{chunk}, \code{lpt} and \code{binpack}.
5-
#'
6-
#' @templateVar ids.default all
7-
#' @template ids
8-
#' @param group.by [\code{character(0)}]\cr
9-
#' If \code{ids} is a \code{\link{data.frame}} with additional columns
10-
#' (in addition to the required column \dQuote{job.id}), then the chunking is performed using
11-
#' subgroups defined by the columns set in \code{group.by}.
12-
#' See example.
13-
#' @inheritParams chunk
14-
#' @template reg
15-
#' @return [\code{\link[data.table]{data.table}}] with columns \dQuote{job.id} and \dQuote{chunk}.
16-
#' @seealso \code{\link{chunk}} \code{\link{binpack}} \code{\link{lpt}}
17-
#' @export
18-
chunkIds = function(ids = NULL, n.chunks = NULL, chunk.size = NULL, group.by = character(0L), reg = getDefaultRegistry()) {
19-
.Deprecated("chunk", package = "batchtools")
20-
assertRegistry(reg)
21-
assertCharacter(group.by, any.missing = FALSE, min.chars = 1L)
22-
ids = convertIds(reg, ids, default = allIds(reg), keep.extra = group.by)
23-
24-
if (length(group.by) > 0L) {
25-
job.id = NULL
26-
if (any(group.by %chnin% names(ids)))
27-
stop("All columns to group by must be provided in the 'ids' table")
28-
ids[, "chunk" := chunk(job.id, n.chunks = n.chunks, chunk.size = chunk.size), by = group.by]
29-
ids[, "chunk" := .GRP, by = c(group.by, "chunk")]
30-
} else {
31-
ids[, "chunk" := chunk(job.id, n.chunks = n.chunks, chunk.size = chunk.size)]
32-
}
33-
34-
return(ids[, c("job.id", "chunk")])
35-
}
36-
37-
381
#' @title Chunk Jobs for Sequential Execution
392
#'
403
#' @description
414
#' Jobs can be partitioned into \dQuote{chunks} to be executed sequentially on the computational nodes.
42-
#' Chunks are defined by providing a data frame with columns \dQuote{job.id} and \dQuote{chunk} (integer).
5+
#' Chunks are defined by providing a data frame with columns \dQuote{job.id} and \dQuote{chunk} (integer)
436
#' to \code{\link{submitJobs}}.
447
#' All jobs with the same chunk number will be grouped together on one node to form a single
458
#' computational job.

R/clusterFunctions.R

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,15 @@ print.SubmitJobResult = function(x, ...) {
141141
#' Simply reads your template file and returns it as a character vector.
142142
#'
143143
#' @param template [\code{character(1)}]\cr
144-
#' Path to template file or single string (containing newlines) which is then passed
145-
#' to \code{\link[brew]{brew}}.
144+
#' Path to template file which is then passed to \code{\link[brew]{brew}}.
146145
#' @param comment.string [\code{character(1)}]\cr
147146
#' Ignore lines starting with this string.
148147
#' @return [\code{character}].
149148
#' @family ClusterFunctionsHelper
150149
#' @export
151150
cfReadBrewTemplate = function(template, comment.string = NA_character_) {
152-
if (stri_detect_fixed(template, "\n")) {
153-
"!DEBUG [cfReadBrewTemplate]: Parsing template from string"
154-
lines = stri_trim_both(stri_split_lines(template)[[1L]])
155-
} else {
156-
"!DEBUG [cfReadBrewTemplate]: Parsing template file '`template`'"
157-
lines = stri_trim_both(readLines(template))
158-
}
151+
"!DEBUG [cfReadBrewTemplate]: Parsing template file '`template`'"
152+
lines = stri_trim_both(readLines(template))
159153

160154
lines = lines[!stri_isempty(lines)]
161155
if (!is.na(comment.string))
@@ -288,42 +282,49 @@ getBatchIds = function(reg, status = "all") {
288282
tab[batch.id %in% reg$status$batch.id]
289283
}
290284

291-
findTemplateFile = function(name) {
292-
assertString(name, min.chars = 1L)
293285

294-
if (stri_detect_fixed(name, "\n"))
295-
return(name)
286+
#' @title Find a batchtools Template File
287+
#'
288+
#' @description
289+
#' This functions returns the path to a template file on the file system.
290+
#' @template template
291+
#' @return [\code{character}] Path to the file or \code{NA} if no template template file was found.
292+
#' @keywords internal
293+
#' @export
294+
findTemplateFile = function(template) {
295+
assertString(template, min.chars = 1L)
296296

297-
if (stri_endswith_fixed(name, ".tmpl")) {
298-
return(assertFileExists(name, access = "r"))
297+
if (stri_endswith_fixed(template, ".tmpl")) {
298+
assertFileExists(template, access = "r")
299+
return(fs::path_abs(template))
299300
}
300301

301302
x = Sys.getenv("R_BATCHTOOLS_SEARCH_PATH")
302303
if (nzchar(x)) {
303-
x = fs::path(x, sprintf("batchtools.%s.tmpl", name))
304-
if (testFileExists(x, access = "r"))
305-
return(fs::path_real(x))
304+
x = fs::path(x, sprintf("batchtools.%s.tmpl", template))
305+
if (fs::file_access(x, "read"))
306+
return(fs::path_abs(x))
306307
}
307308

308-
x = sprintf("batchtools.%s.tmpl", name)
309-
if (testFileExists(x, access = "r"))
310-
return(fs::path_real(x))
309+
x = sprintf("batchtools.%s.tmpl", template)
310+
if (fs::file_access(x, "read"))
311+
return(fs::path_abs(x))
311312

312-
x = fs::path(user_config_dir("batchtools", expand = FALSE), sprintf("%s.tmpl", name))
313-
if (testFileExists(x, access = "r"))
313+
x = fs::path(user_config_dir("batchtools", expand = FALSE), sprintf("%s.tmpl", template))
314+
if (fs::file_access(x, "read"))
314315
return(x)
315316

316-
x = fs::path("~", sprintf(".batchtools.%s.tmpl", name))
317-
if (testFileExists(x, access = "r"))
318-
return(fs::path_real(x))
317+
x = fs::path("~", sprintf(".batchtools.%s.tmpl", template))
318+
if (fs::file_access(x, "read"))
319+
return(fs::path_abs(x))
319320

320-
x = fs::path(site_config_dir("batchtools"), sprintf("%s.tmpl", name))
321-
if (testFileExists(x, access = "r"))
321+
x = fs::path(site_config_dir("batchtools"), sprintf("%s.tmpl", template))
322+
if (fs::file_access(x, "read"))
322323
return(x)
323324

324-
x = system.file("templates", sprintf("%s.tmpl", name), package = "batchtools")
325-
if (testFileExists(x, access = "r"))
325+
x = system.file("templates", sprintf("%s.tmpl", template), package = "batchtools")
326+
if (fs::file_access(x, "read"))
326327
return(x)
327328

328-
stopf("Argument 'template' (=\"%s\") must point to a readable template file or contain the template itself as string (containing at least one newline)", name)
329+
return(NA_character_)
329330
}

R/clusterFunctionsLSF.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
#' @note
1919
#' Array jobs are currently not supported.
2020
#'
21-
#' @templateVar cf.name lsf
2221
#' @template template
2322
#' @inheritParams makeClusterFunctions
2423
#' @return [\code{\link{ClusterFunctions}}].
2524
#' @family ClusterFunctions
2625
#' @export
2726
makeClusterFunctionsLSF = function(template = "lsf", scheduler.latency = 1, fs.latency = 65) { # nocov start
2827
template = findTemplateFile(template)
28+
if (testScalarNA(template))
29+
stopf("Argument 'template' (=\"%s\") must point to a readable template file or contain the template itself as string (containing at least one newline)", template)
2930
template = cfReadBrewTemplate(template)
3031

3132
# When LSB_BJOBS_CONSISTENT_EXIT_CODE = Y, the bjobs command exits with 0 only

R/clusterFunctionsOpenLava.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
#' @note
1919
#' Array jobs are currently not supported.
2020
#'
21-
#' @templateVar cf.name openlava
2221
#' @template template
2322
#' @inheritParams makeClusterFunctions
2423
#' @return [\code{\link{ClusterFunctions}}].
2524
#' @family ClusterFunctions
2625
#' @export
2726
makeClusterFunctionsOpenLava = function(template = "openlava", scheduler.latency = 1, fs.latency = 65) { # nocov start
2827
template = findTemplateFile(template)
28+
if (testScalarNA(template))
29+
stopf("Argument 'template' (=\"%s\") must point to a readable template file", template)
2930
template = cfReadBrewTemplate(template)
3031

3132
# When LSB_BJOBS_CONSISTENT_EXIT_CODE = Y, the bjobs command exits with 0 only

0 commit comments

Comments
 (0)