Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 4eb3773

Browse files
authored
Fix: Do not use task chunk size during cloud combine function (#152)
* Fix task counts when group of tasks are not equal * Added chunksize test * Fixed pass case
1 parent 169e75f commit 4eb3773

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

inst/startup/merger.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enableCloudCombine <- azbatchenv$enableCloudCombine
3131
cloudCombine <- azbatchenv$cloudCombine
3232

3333
if (typeof(cloudCombine) == "list" && enableCloudCombine) {
34-
results <- vector("list", batchTasksCount * chunkSize)
34+
results <- vector("list", batchTasksCount)
3535
count <- 1
3636

3737
status <- tryCatch({
@@ -48,7 +48,7 @@ if (typeof(cloudCombine) == "list" && enableCloudCombine) {
4848
"https://github.com/Azure/doAzureParallel/blob/master/docs/40-troubleshooting.md"))
4949
}
5050

51-
results <- vector("list", length(files) * chunkSize)
51+
results <- vector("list", length(files))
5252

5353
for (i in 1:length(files)) {
5454
task <- readRDS(files[i])
@@ -62,7 +62,7 @@ if (typeof(cloudCombine) == "list" && enableCloudCombine) {
6262
}
6363
}
6464

65-
for (t in 1:length(chunkSize)) {
65+
for (t in 1:length(task)) {
6666
results[count] <- task[t]
6767
count <- count + 1
6868
}
@@ -84,7 +84,7 @@ if (typeof(cloudCombine) == "list" && enableCloudCombine) {
8484

8585
if (file.exists(taskResult)) {
8686
task <- readRDS(taskResult)
87-
for (t in 1:length(chunkSize)) {
87+
for (t in 1:length(task)) {
8888
results[count] <- task[t]
8989
count <- count + 1
9090
}

tests/testthat/test-live.R

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,32 @@ test_that("Scenario Test", {
2727
testthat::expect_equal(res,
2828
list(2, 2, 2, 2))
2929
})
30+
31+
test_that("Chunksize Test", {
32+
testthat::skip_on_travis()
33+
credentialsFileName <- "credentials.json"
34+
clusterFileName <- "cluster.json"
35+
36+
doAzureParallel::generateCredentialsConfig(credentialsFileName)
37+
doAzureParallel::generateClusterConfig(clusterFileName)
38+
39+
doAzureParallel::setCredentials(credentialsFileName)
40+
cluster <- doAzureParallel::makeCluster(clusterFileName)
41+
doAzureParallel::registerDoAzureParallel(cluster)
42+
43+
'%dopar%' <- foreach::'%dopar%'
44+
res <-
45+
foreach::foreach(i = 1:10, .options.azure = list(chunkSize = 3)) %dopar% {
46+
i
47+
}
48+
49+
doAzureParallel::stopCluster(cluster)
50+
51+
testthat::expect_equal(length(res),
52+
10)
53+
54+
for (i in 1:10) {
55+
testthat::expect_equal(res[[i]],
56+
i)
57+
}
58+
})

0 commit comments

Comments
 (0)