31
31
# ' @param array.var [\code{character(1)}]\cr
32
32
# ' Name of the environment variable set by the scheduler to identify IDs of job arrays.
33
33
# ' Default is \code{NA} for no array support.
34
- # ' @param store.job [\code{logical(1)}]\cr
34
+ # ' @param store.job.collection [\code{logical(1)}]\cr
35
35
# ' Flag to indicate that the cluster function implementation of \code{submitJob} can not directly handle \code{\link{JobCollection}} objects.
36
36
# ' If set to \code{FALSE}, the \code{\link{JobCollection}} is serialized to the file system before submitting the job.
37
+ # ' @param store.job.files [\code{logical(1)}]\cr
38
+ # ' Flag to indicate that job files need to be stored in the file directory.
39
+ # ' If set to \code{FALSE} (default), the job file is created in a temporary directory, otherwise (or if the debug mode is enabled) in
40
+ # ' the subdirectory \code{jobs} of the \code{file.dir}.
37
41
# ' @param scheduler.latency [\code{numeric(1)}]\cr
38
42
# ' Time to sleep after important interactions with the scheduler to ensure a sane state.
39
43
# ' Currently only triggered after calling \code{\link{submitJobs}}.
50
54
# ' @family ClusterFunctions
51
55
# ' @family ClusterFunctionsHelper
52
56
makeClusterFunctions = function (name , submitJob , killJob = NULL , listJobsQueued = NULL , listJobsRunning = NULL ,
53
- array.var = NA_character_ , store.job = FALSE , scheduler.latency = 0 , fs.latency = NA_real_ , hooks = list ()) {
57
+ array.var = NA_character_ , store.job.collection = FALSE , store.job.files = FALSE , scheduler.latency = 0 ,
58
+ fs.latency = NA_real_ , hooks = list ()) {
54
59
assertList(hooks , types = " function" , names = " unique" )
55
60
assertSubset(names(hooks ), unlist(batchtools $ hooks , use.names = FALSE ))
56
61
@@ -61,7 +66,8 @@ makeClusterFunctions = function(name, submitJob, killJob = NULL, listJobsQueued
61
66
listJobsQueued = assertFunction(listJobsQueued , " reg" , null.ok = TRUE ),
62
67
listJobsRunning = assertFunction(listJobsRunning , " reg" , null.ok = TRUE ),
63
68
array.var = assertString(array.var , na.ok = TRUE ),
64
- store.job = assertFlag(store.job ),
69
+ store.job.collection = assertFlag(store.job.collection ),
70
+ store.job.files = assertFlag(store.job.files ),
65
71
scheduler.latency = assertNumber(scheduler.latency , lower = 0 ),
66
72
fs.latency = assertNumber(fs.latency , lower = 0 , na.ok = TRUE ),
67
73
hooks = hooks ),
@@ -181,7 +187,11 @@ cfReadBrewTemplate = function(template, comment.string = NA_character_) {
181
187
cfBrewTemplate = function (reg , text , jc ) {
182
188
assertString(text )
183
189
184
- outfile = if (batchtools $ debug ) fp(reg $ file.dir , " jobs" , sprintf(" %s.job" , jc $ job.hash )) else tempfile(" job" )
190
+ outfile = if (batchtools $ debug || reg $ cluster.functions $ store.job.files ) {
191
+ fp(reg $ file.dir , " jobs" , sprintf(" %s.job" , jc $ job.hash ))
192
+ } else {
193
+ tempfile(fileext = " job" )
194
+ }
185
195
parent.env(jc ) = asNamespace(" batchtools" )
186
196
on.exit(parent.env(jc ) <- emptyenv())
187
197
" !DEBUG [cfBrewTemplate]: Brewing template to file '`outfile`'"
@@ -235,16 +245,18 @@ cfHandleUnknownSubmitError = function(cmd, exit.code, output) {
235
245
# ' @param max.tries [\code{integer(1)}]\cr
236
246
# ' Number of total times to try execute the OS command in cases of failures.
237
247
# ' Default is \code{3}.
248
+ # ' @inheritParams runOSCommand
238
249
# ' @return \code{TRUE} on success. An exception is raised otherwise.
239
250
# ' @family ClusterFunctionsHelper
240
251
# ' @export
241
- cfKillJob = function (reg , cmd , args = character (0L ), max.tries = 3L ) {
252
+ cfKillJob = function (reg , cmd , args = character (0L ), max.tries = 3L , nodename = " localhost " ) {
242
253
assertString(cmd , min.chars = 1L )
243
254
assertCharacter(args , any.missing = FALSE )
255
+ assertString(nodename )
244
256
max.tries = asCount(max.tries )
245
257
246
258
for (i in seq_len(max.tries )) {
247
- res = runOSCommand(cmd , args )
259
+ res = runOSCommand(cmd , args , nodename = nodename )
248
260
if (res $ exit.code == 0L )
249
261
return (TRUE )
250
262
Sys.sleep(1 )
0 commit comments