Skip to content

Commit 03294c2

Browse files
committed
fix array jobs
1 parent 6fed947 commit 03294c2

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

R/submitJobs.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,8 @@ submitJobs = function(ids = NULL, resources = list(), sleep = NULL, reg = getDef
276276
submit = reg$cluster.functions$submitJob(reg = reg, jc = jc)
277277

278278
if (submit$status == 0L) {
279-
if (!testString(submit$batch.id, na.ok = FALSE)) {
280-
print(str(submit))
281-
stopf("Cluster function did not return a valid batch.id")
279+
if (!testCharacter(submit$batch.id, any.missing = FALSE, min.len = 1L)) {
280+
stopf("Cluster function did not return valid batch ids:\n%s", stri_flatten(capture.output(str(submit$batch.id)), "\n"))
282281
}
283282
reg$status[ids.chunk,
284283
c("submitted", "started", "done", "error", "mem.used", "resource.id", "batch.id", "log.file", "job.hash") :=

tests/testthat/test_JobCollection.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@ test_that("makeJobCollection.ExperimentCollection", {
6262

6363
expect_is(jc, "ExperimentCollection")
6464
})
65+
66+
test_that("chunks.as.arrayjobs is stored", {
67+
reg = makeTestRegistry(file.dir = NA, make.default = FALSE)
68+
ids = batchMap(identity, 1:2, reg = reg)
69+
resources = list(chunks.as.arrayjobs = TRUE)
70+
jc = makeJobCollection(ids, resources = resources, reg = reg)
71+
expect_true(jc$array.jobs)
72+
})

tests/testthat/test_submitJobs.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test_that("submitJobs", {
2727
expect_equal(uniqueN(reg$status$job.hash), 2)
2828
})
2929

30-
test_that("submitJobs: per job resources", {
30+
test_that("per job resources", {
3131
reg = makeTestRegistry()
3232

3333
fun = function(...) list(...)
@@ -45,3 +45,13 @@ test_that("submitJobs: per job resources", {
4545
ids$chunk = 1L
4646
expect_error(submitJobs(ids, reg = reg), "per-job")
4747
})
48+
49+
test_that("chunks.as.arrayjobs is passed down", {
50+
reg = makeTestRegistry()
51+
fun = function(...) list(...)
52+
ids = batchMap(fun, i = 1:3, reg = reg)
53+
ids$chunk = 1L
54+
submitJobs(ids, resources = resources, reg = reg)
55+
56+
57+
})

0 commit comments

Comments
 (0)