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

Commit

Permalink
Collapsing pool package installation on start task command line (#191)
Browse files Browse the repository at this point in the history
* Collasping the R package installations for pool installation

* Renamed script variable

* Fixed pool installation test

* Fixed length test
  • Loading branch information
brnleehng authored Dec 13, 2017
1 parent 68b2fa4 commit 89dbba9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
14 changes: 6 additions & 8 deletions R/commandLineUtilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ getJobPackageInstallationCommand <- function(type, packages) {
}

getPoolPackageInstallationCommand <- function(type, packages) {
poolInstallationCommand <- character(length(packages))

sharedPackagesDirectory <- "/mnt/batch/tasks/shared/R/packages"

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

# At this point we cannot use install_cran.R and install_github.R because they are not yet available.
if (type == "cran") {
script <-
poolInstallationCommand <-
paste(installCommand,
paste("-e",
libPathsCommand,
"install.packages(args[1])\' %s")
"install.packages(args)\'")
)
}
else if (type == "github") {
script <-
poolInstallationCommand <-
paste(
installCommand,
paste(
"-e",
libPathsCommand,
"devtools::install_github(args[1])\' %s"
"devtools::install_github(args)\'"
)
)
}
else if (type == "bioconductor") {
script <- "Rscript /mnt/batch/tasks/startup/wd/install_bioconductor.R %s"
poolInstallationCommand <- "Rscript /mnt/batch/tasks/startup/wd/install_bioconductor.R"
}
else {
stop("Using an incorrect package source")
}

for (i in 1:length(packages)) {
poolInstallationCommand[i] <- sprintf(script, packages[i])
poolInstallationCommand <- paste(poolInstallationCommand, packages[i])
}

poolInstallationCommand
Expand Down
15 changes: 4 additions & 11 deletions tests/testthat/test-package-installation.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test_that("successfully create github job package command line", {
test_that("successfully create cran pool package command line", {
poolInstallation <-
getPoolPackageInstallationCommand("cran", c("hts", "lubridate", "tidyr"))
expect_equal(length(poolInstallation), 3)
expect_equal(length(poolInstallation), 1)

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

expected <-
c(
paste(libPathCommand, "install.packages(args[1])\' hts"),
paste(libPathCommand, "install.packages(args[1])\' lubridate"),
paste(libPathCommand, "install.packages(args[1])\' tidyr")
paste(libPathCommand, "install.packages(args)\' hts lubridate tidyr")
)

expect_equal(poolInstallation, expected)
Expand All @@ -41,7 +39,7 @@ test_that("successfully create cran pool package command line", {
test_that("successfully create github pool package command line", {
poolInstallation <-
getPoolPackageInstallationCommand("github", c("Azure/doAzureParallel", "Azure/rAzureBatch"))
expect_equal(length(poolInstallation), 2)
expect_equal(length(poolInstallation), 1)

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

expected <-
c(
paste(libPathCommand, "devtools::install_github(args[1])\' Azure/doAzureParallel"),
paste(libPathCommand, "devtools::install_github(args[1])\' Azure/rAzureBatch")
paste(libPathCommand, "devtools::install_github(args)\' Azure/doAzureParallel Azure/rAzureBatch")
)

expect_equal(poolInstallation, expected)
Expand All @@ -61,15 +58,11 @@ test_that("successfully create github pool package command line", {
test_that("successfully create bioconductor pool package command line", {
poolInstallation <-
getPoolPackageInstallationCommand("bioconductor", c("IRanges", "a4"))
cat(poolInstallation)
expect_equal(length(poolInstallation), 2)

expected <-
c(
paste("Rscript /mnt/batch/tasks/startup/wd/install_bioconductor.R",
"IRanges",
sep = " "),
paste("Rscript /mnt/batch/tasks/startup/wd/install_bioconductor.R",
"a4",
sep = " ")
)
Expand Down

0 comments on commit 89dbba9

Please sign in to comment.