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

Commit 89dbba9

Browse files
authored
Collapsing pool package installation on start task command line (#191)
* Collasping the R package installations for pool installation * Renamed script variable * Fixed pool installation test * Fixed length test
1 parent 68b2fa4 commit 89dbba9

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

R/commandLineUtilities.R

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ getJobPackageInstallationCommand <- function(type, packages) {
2121
}
2222

2323
getPoolPackageInstallationCommand <- function(type, packages) {
24-
poolInstallationCommand <- character(length(packages))
25-
2624
sharedPackagesDirectory <- "/mnt/batch/tasks/shared/R/packages"
2725

2826
libPathsCommand <- paste0('\'.libPaths( c( \\\"',
@@ -35,33 +33,33 @@ getPoolPackageInstallationCommand <- function(type, packages) {
3533

3634
# At this point we cannot use install_cran.R and install_github.R because they are not yet available.
3735
if (type == "cran") {
38-
script <-
36+
poolInstallationCommand <-
3937
paste(installCommand,
4038
paste("-e",
4139
libPathsCommand,
42-
"install.packages(args[1])\' %s")
40+
"install.packages(args)\'")
4341
)
4442
}
4543
else if (type == "github") {
46-
script <-
44+
poolInstallationCommand <-
4745
paste(
4846
installCommand,
4947
paste(
5048
"-e",
5149
libPathsCommand,
52-
"devtools::install_github(args[1])\' %s"
50+
"devtools::install_github(args)\'"
5351
)
5452
)
5553
}
5654
else if (type == "bioconductor") {
57-
script <- "Rscript /mnt/batch/tasks/startup/wd/install_bioconductor.R %s"
55+
poolInstallationCommand <- "Rscript /mnt/batch/tasks/startup/wd/install_bioconductor.R"
5856
}
5957
else {
6058
stop("Using an incorrect package source")
6159
}
6260

6361
for (i in 1:length(packages)) {
64-
poolInstallationCommand[i] <- sprintf(script, packages[i])
62+
poolInstallationCommand <- paste(poolInstallationCommand, packages[i])
6563
}
6664

6765
poolInstallationCommand

tests/testthat/test-package-installation.R

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test_that("successfully create github job package command line", {
2020
test_that("successfully create cran pool package command line", {
2121
poolInstallation <-
2222
getPoolPackageInstallationCommand("cran", c("hts", "lubridate", "tidyr"))
23-
expect_equal(length(poolInstallation), 3)
23+
expect_equal(length(poolInstallation), 1)
2424

2525
libPathCommand <-
2626
paste(
@@ -30,9 +30,7 @@ test_that("successfully create cran pool package command line", {
3030

3131
expected <-
3232
c(
33-
paste(libPathCommand, "install.packages(args[1])\' hts"),
34-
paste(libPathCommand, "install.packages(args[1])\' lubridate"),
35-
paste(libPathCommand, "install.packages(args[1])\' tidyr")
33+
paste(libPathCommand, "install.packages(args)\' hts lubridate tidyr")
3634
)
3735

3836
expect_equal(poolInstallation, expected)
@@ -41,7 +39,7 @@ test_that("successfully create cran pool package command line", {
4139
test_that("successfully create github pool package command line", {
4240
poolInstallation <-
4341
getPoolPackageInstallationCommand("github", c("Azure/doAzureParallel", "Azure/rAzureBatch"))
44-
expect_equal(length(poolInstallation), 2)
42+
expect_equal(length(poolInstallation), 1)
4543

4644
libPathCommand <-
4745
paste(
@@ -51,8 +49,7 @@ test_that("successfully create github pool package command line", {
5149

5250
expected <-
5351
c(
54-
paste(libPathCommand, "devtools::install_github(args[1])\' Azure/doAzureParallel"),
55-
paste(libPathCommand, "devtools::install_github(args[1])\' Azure/rAzureBatch")
52+
paste(libPathCommand, "devtools::install_github(args)\' Azure/doAzureParallel Azure/rAzureBatch")
5653
)
5754

5855
expect_equal(poolInstallation, expected)
@@ -61,15 +58,11 @@ test_that("successfully create github pool package command line", {
6158
test_that("successfully create bioconductor pool package command line", {
6259
poolInstallation <-
6360
getPoolPackageInstallationCommand("bioconductor", c("IRanges", "a4"))
64-
cat(poolInstallation)
65-
expect_equal(length(poolInstallation), 2)
6661

6762
expected <-
6863
c(
6964
paste("Rscript /mnt/batch/tasks/startup/wd/install_bioconductor.R",
7065
"IRanges",
71-
sep = " "),
72-
paste("Rscript /mnt/batch/tasks/startup/wd/install_bioconductor.R",
7366
"a4",
7467
sep = " ")
7568
)

0 commit comments

Comments
 (0)