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

Commit

Permalink
Added Travis CI (#23)
Browse files Browse the repository at this point in the history
* Create .travis.yml

* Added travis to .Rbuildignore

* Added r package github installation

* Skipping on travis

* Added don't run on examples for R travis CI

* Warnings are errors
  • Loading branch information
brnleehng authored Jun 14, 2017
1 parent 15c13c8 commit 96c3ba2
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 31 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: R
sudo: false
cache: packages
warnings_are_errors: false

r_github_packages:
- Azure/rAzureBatch
7 changes: 5 additions & 2 deletions R/autoscale.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ getAutoscaleFormula <- function(formulaName, dedicatedMin, dedicatedMax, lowPrio
#' @param lowPriorityMin The minimum number of low priority nodes
#' @param lowPriorityMax The maximum number of low priority nodes
#' @param algorithm Current built-in autoscale formulas: QUEUE, MAX_CPU, WEEKEND, WEEKDAY
#' @param timeInterval
#' @param timeInterval Time interval at which to automatically adjust the pool size according to the autoscale formula
#'
#' @examples
#' resizeCluster(cluster, dedicatedMin = 2, dedicatedMax = 6, dedicatedMin = 2, dedicatedMax = 6, algorithm = "QUEUE", timeInterval = "PT10M")
#' \dontrun{
#' resizeCluster(cluster, dedicatedMin = 2, dedicatedMax = 6,
#' dedicatedMin = 2, dedicatedMax = 6, algorithm = "QUEUE", timeInterval = "PT10M")
#' }
#' @export
resizeCluster <- function(cluster,
dedicatedMin,
Expand Down
16 changes: 9 additions & 7 deletions R/cluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#' @return The request to the Batch service was successful.
#' @examples {
#' generateCredentialsConfig("test_config.json")
#' generateCredentialsConfig("test_config.json", batchAccount = "testbatchaccount", batchKey = "test_batch_account_key", batchUrl = "http://testbatchaccount.azure.com", storageAccount = "teststorageaccount", storageKey = "test_storage_account_key")
#' generateCredentialsConfig("test_config.json", batchAccount = "testbatchaccount",
#' batchKey = "test_batch_account_key", batchUrl = "http://testbatchaccount.azure.com",
#' storageAccount = "teststorageaccount", storageKey = "test_storage_account_key")
#' }
#' @export
generateCredentialsConfig <- function(fileName, ...){
Expand Down Expand Up @@ -96,14 +98,16 @@ generateClusterConfig <- function(fileName, ...){

#' Creates an Azure cloud-enabled cluster.
#'
#' @param fileName Cluster configuration's file name
#' @param clusterSetting Cluster configuration's file name
#' @param fullName A boolean flag for checking the file full name
#' @param wait A boolean flag to wait for all nodes to boot up
#' @param resourceFiles A list of files that Batch will download to the compute node before running the command line
#'
#' @return The request to the Batch service was successful.
#' @examples
#' \dontrun{
#' cluster <- makeCluster("cluster_config.json", fullName = TRUE, wait = TRUE)
#' }
#' @export
makeCluster <- function(clusterSetting = "cluster_settings.json", fullName = FALSE, wait = TRUE, resourceFiles = list()){
if(fullName){
Expand Down Expand Up @@ -166,23 +170,21 @@ makeCluster <- function(clusterSetting = "cluster_settings.json", fullName = FAL
#' @param cluster The cluster configuration that was created in \code{makeCluster}
#'
#' @examples
#' \dontrun{
#' clusterConfiguration <- makeCluster("cluster_settings.json")
#' stopCluster(clusterConfiguration)
#' }
#' @export
stopCluster <- function(cluster){
deletePool(cluster$poolId)

print(sprintf("Your %s cluster has been destroyed.", cluster$poolId))
}

#' Deletes the cluster from your Azure account.
#' Set azure credentials to R session.
#'
#' @param fileName The cluster configuration that was created in \code{makeCluster}
#'
#' @return The request to the Batch service was successful.
#' @examples
#' clusterConfiguration <- makeCluster("cluster_settings.json")
#' stopCluster(clusterConfiguration)
#' @export
setCredentials <- function(fileName = "az_config.json"){
if(file.exists(fileName)){
Expand Down
12 changes: 10 additions & 2 deletions R/utility.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ linuxWrapCommands <- function(commands = c()){
#' @param jobIds A character vector of job ids
#'
#' @examples
#' \dontrun{
#' getJobList(c("job-001", "job-002"))
#' }
#' @export
getJobList <- function(jobIds = c()){
filter <- ""
Expand Down Expand Up @@ -80,7 +82,9 @@ getJobList <- function(jobIds = c()){
#' @param timeout Timeout in seconds, default timeout is one day
#'
#' @examples
#' \dontrun{
#' waitForNodesToComplete(clusterId = "testCluster", timeout = 3600)
#' }
#' @export
waitForNodesToComplete <- function(clusterId, timeout = 86400){
print("Booting compute nodes. . . ")
Expand Down Expand Up @@ -147,13 +151,17 @@ waitForNodesToComplete <- function(clusterId, timeout = 86400){
}

#' Download the results of the job
#'
#' @param ... Further named parameters
#' \itemize{
#' \item{"container"}: {The container to download from.}
#' }
#' @param jobId The jobId to download from
#' @param container The container to download from
#'
#' @return The results from the job.
#' @examples
#' \dontrun{
#' getJobResult(jobId = "job-001")
#' }
#' @export
getJobResult <- function(jobId = "", ...){
args <- list(...)
Expand Down
4 changes: 3 additions & 1 deletion man/generateCredentialsConfig.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/getJobList.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion man/getJobResult.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/makeCluster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions man/resizeCluster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions man/setCredentials.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/stopCluster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/waitForNodesToComplete.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 30 additions & 5 deletions tests/testthat/test-integration.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
context("generate cluster config")

test_that("creating a cluster config file", {
test_that("creating a credentials file", {
skip_on_travis()

configFileName <- "testthat.json"

generateCredentialsConfig(configFileName)
config <- jsonlite::fromJSON(configFileName)

expect_false(is.null(config$batchAccount$name))
expect_false(is.null(config$batchAccount$key))
expect_false(is.null(config$batchAccount$url))

file.remove(configFileName)
})

test_that("creating a cluster file", {
skip_on_travis()

configFileName <- "testthat.json"

generateClusterConfig(configFileName)
Expand All @@ -15,6 +32,8 @@ test_that("creating a cluster config file", {
})

test_that("End to end integration simple sum foreach", {
skip_on_travis()

configFileName <- "testthat.json"

batchAccountName <- Sys.getenv("AZ_BATCH_ACCOUNT_NAME")
Expand All @@ -24,7 +43,7 @@ test_that("End to end integration simple sum foreach", {
storageAccountName <- Sys.getenv("AZ_STORAGE_ACCOUNT_NAME")
storageAccountKey <- Sys.getenv("AZ_STORAGE_ACCOUNT_KEY")

generateClusterConfig(configFileName,
generateCredentialsConfig(configFileName,
batchAccount = batchAccountName,
batchKey = batchAccountKey,
batchUrl = batchAccountUrl,
Expand All @@ -48,6 +67,8 @@ test_that("End to end integration simple sum foreach", {
})

test_that("End to end integration job with wait", {
skip_on_travis()

configFileName <- "testthat.json"

batchAccountName <- Sys.getenv("AZ_BATCH_ACCOUNT_NAME")
Expand All @@ -57,7 +78,7 @@ test_that("End to end integration job with wait", {
storageAccountName <- Sys.getenv("AZ_STORAGE_ACCOUNT_NAME")
storageAccountKey <- Sys.getenv("AZ_STORAGE_ACCOUNT_KEY")

generateClusterConfig(configFileName,
generateCredentialsConfig(configFileName,
batchAccount = batchAccountName,
batchKey = batchAccountKey,
batchUrl = batchAccountUrl,
Expand Down Expand Up @@ -96,6 +117,8 @@ test_that("End to end integration job with wait", {
})

test_that("End to end integration job with chunks", {
skip_on_travis()

configFileName <- "testthat.json"

batchAccountName <- Sys.getenv("AZ_BATCH_ACCOUNT_NAME")
Expand All @@ -105,14 +128,16 @@ test_that("End to end integration job with chunks", {
storageAccountName <- Sys.getenv("AZ_STORAGE_ACCOUNT_NAME")
storageAccountKey <- Sys.getenv("AZ_STORAGE_ACCOUNT_KEY")

generateClusterConfig(configFileName,
generateCredentialsConfig(configFileName,
batchAccount = batchAccountName,
batchKey = batchAccountKey,
batchUrl = batchAccountUrl,
storageAccount = storageAccountName,
storageKey = storageAccountKey)

cluster <- makeCluster(configFileName)
setCredentials("testthat.json")

cluster <- makeCluster("cluster.json")

registerDoAzureParallel(cluster)

Expand Down

0 comments on commit 96c3ba2

Please sign in to comment.