Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from devel for Release 1.1 #13

Merged
merged 11 commits into from
Apr 1, 2016
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: GRAPLEr
Title: Distributed computing made easy for lake ecology modeling
Version: 1.0.2
Version: 1.1.0
Authors@R: c(person("Ken", "S", role = c("aut", "cre"),
email = "kcratie@acis.ufl.edu"),
person("Renato", "F", role = "cph"),
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
export(GrapleAbortExperiment)
export(GrapleCheckExperimentCompletion)
export(GrapleCheckService)
export(GrapleCheckVersionCompatibility)
export(GrapleGetExperimentJobResults)
export(GrapleGetExperimentResults)
export(GrapleListFilters)
export(GrapleRunExperiment)
export(GrapleRunExperimentJob)
export(GrapleRunExperimentSweep)
76 changes: 74 additions & 2 deletions R/GrapleR.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ GrapleRunExperiment<-function(submissionURL, ExperimentDir, FilterName)
td<-getwd()
setwd(ExperimentDir)
simdirs <- dir(".")
if("Results" %in% simdirs) {
print("Results found in experiment directory!")
print("Please delete and run the experiment")
return()
}
tarfile = file.path(ExperimentDir, "sim.tar.gz")
tar(tarfile, simdirs, compression="gz", compression_level = 6, tar="internal")

Expand Down Expand Up @@ -98,6 +103,11 @@ GrapleCheckExperimentCompletion <- function(submissionURL, experimentId)
GrapleGetExperimentResults <- function(submissionURL, experimentId)
{
td<-getwd()
if("Results" %in% dir()) {
print("Results found in experiment directory!")
print("Please delete and get the results")
return()
}
qurl <- paste(submissionURL, "GrapleRunResults", experimentId, sep="/")
status<- getURL(qurl)

Expand Down Expand Up @@ -150,12 +160,18 @@ GrapleRunExperimentSweep <- function(submissionURL, simDir, driverFileName, para
setwd("../tempGRAPLE")
tarfile = file.path(simDir, "sim.tar.gz")
setwd(simDir)
if("Results" %in% dir()) {
print("Results found in experiment directory!")
print("Please delete and run the experiment")
unlink("../tempGRAPLE", recursive = TRUE)
return()
}
tar(tarfile, ".", compression="gz", compression_level = 6, tar="internal")

qurl <- paste(submissionURL, "GrapleRunMetOffset", sep="/")

status <- postForm(qurl, files=fileUpload(tarfile))
print(status)
print(fromJSON(status))
expid <- substr(status[1], start=13, stop=52)

if (file.exists(tarfile)) file.remove(tarfile)
Expand All @@ -168,7 +184,7 @@ GrapleRunExperimentSweep <- function(submissionURL, simDir, driverFileName, para
qurl <- paste(submissionURL, "TriggerSimulation", params, sep="/")
print(qurl)
status = postForm(qurl, t="none")
print(paste0("Status:", status))
print(paste0("Status:", fromJSON(status)))
#if(status <> "Success") print("Failed to start experiment")
setwd(td)
return (expid)
Expand Down Expand Up @@ -210,6 +226,12 @@ GrapleRunExperimentJob <- function(submissionURL, simDir, FilterName)
setwd("../tempGRAPLE")
tarfile = file.path(getwd(), "sweepexp.tar.gz")
setwd(simDir)
if("Results" %in% dir()) {
print("Results found in experiment directory!")
print("Please delete and run the experiment")
unlink("../tempGRAPLE", recursive = TRUE)
return()
}
tar(tarfile, ".", compression="gz", compression_level = 6, tar="internal")
if(missing(FilterName)){
qurl <- paste(submissionURL, "GrapleRunMetSample", sep="/")
Expand Down Expand Up @@ -245,6 +267,11 @@ GrapleRunExperimentJob <- function(submissionURL, simDir, FilterName)
GrapleGetExperimentJobResults <- function(submissionURL, experimentId)
{
td<-getwd()
if("Results" %in% dir()) {
print("Results found in experiment directory!")
print("Please delete and run the experiment")
return()
}
qurl <- paste(submissionURL, "GrapleRunResultsMetSample", experimentId, sep="/")
status<- getURL(qurl)

Expand Down Expand Up @@ -285,3 +312,48 @@ GrapleAbortExperiment <- function(submissionURL, experimentId)
status<- getURL(qurl)
return (fromJSON(status))
}

#' @title Retrieves the list of post process operation scripts
#' @description
#' This function allows you to retrieve list of all the post-process operation scripts
#' @param submissionURL URL:Port of the GRAPLEr web service
#' @return a comma seperated string of file names
#' @keywords Graple ListFilters
#' @export
#' @examples
#' \dontrun{
#' graplerURL<-"http://graple-service.cloudapp.net"
#' GrapleListFilters(graplerURL)
#' }
GrapleListFilters <- function(submissionURL)
{
qurl <- paste(submissionURL, "GrapleListFilters", sep="/")
status <- getURL(qurl)
return (toString(fromJSON(status)))
}

#' @title Checks version compatibility between R package and Graple web service
#' @description
#' This function allows you to check version compatibility between R package and
#' Graple Web Service
#' @param submissionURL URL:Port of the GRAPLEr web service
#' @return true if versions are compatible else false
#' @keywords Graple CheckVersionCompatibility
#' @export
#' @examples
#' \dontrun{
#' graplerURL<-"http://graple-service.cloudapp.net"
#' GrapleCheckVersionCompatibility(graplerURL)
#' }
GrapleCheckVersionCompatibility <- function(submissionURL)
{
compatibleVersions <- c(packageVersion("GRAPLEr"), "1.0.2")
qurl <- paste(submissionURL, "GrapleGetVersion", sep="/")
status <- getURL(qurl)
serviceVersion <- fromJSON(status)
if(serviceVersion %in% compatibleVersions)
return(TRUE)
else
return(TRUE)
}

27 changes: 27 additions & 0 deletions man/GrapleCheckVersionCompatibility.Rd

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

26 changes: 26 additions & 0 deletions man/GrapleListFilters.Rd

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

18 changes: 12 additions & 6 deletions test/testGrapleR.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ library("RCurl")
library("jsonlite")
library("GRAPLEr")

graplerURL<-"http://graple.acis.ufl.edu"
graplerURL<-"http://10.244.37.64:5000"
#graplerURL<-"http://graple.acis.ufl.edu"
print(GrapleCheckService(graplerURL))

#Returns the list of post-processing scripts available on the server
print(GrapleListFilters(graplerURL))

print(GrapleCheckVersionCompatibility(graplerURL))

#Experiment 1: Your own handcrafted simulations
expRootDir<-"c:/ExpRoot/Exp1"
setwd(expRootDir)
Expand All @@ -18,13 +24,13 @@ GrapleGetExperimentResults(graplerURL, expId1)

#Experiment 2 - Your own handcrafted simulations w/ post processing R-Filter(experimental feature)
expRootDir<-"c:/ExpRoot/Exp2"
filterName <- "Filter1.R"
filterName <- "Filter2.R"
setwd(expRootDir)
expId2<-GrapleRunExperiment(graplerURL, expRootDir, filterName)
GrapleCheckExperimentCompletion(graplerURL, expId2)
GrapleGetExperimentResults(graplerURL, expId2)

#Experiment 3: An increment type sweep experiment.
#Experiment 3: An increment type sweep experiment.
#Paramters are passed directly to funtion on invocation.
simDir3="c:/ExpRoot/Exp3"
driverFileName="met_hourly.csv"
Expand All @@ -44,13 +50,13 @@ parameterName="AirTemp"
startValue=-2
endValue=2
numberOfIncrements=10
filterName = "Filter1.R"
filterName = "Filter2.R"
setwd(simDir4)
expId4<-GrapleRunExperimentSweep(graplerURL, simDir4, driverFileName, parameterName, startValue, endValue, numberOfIncrements, filterName)
GrapleCheckExperimentCompletion(graplerURL, expId4)
GrapleGetExperimentResults(graplerURL, expId4)

#Experiment 5: A sweep experiment using using various distributions for generating ranges.
#Experiment 5: A sweep experiment using using various distributions for generating ranges.
#Paramters specified via an input file.
simDir5="c:/ExpRoot/Exp5"
setwd(simDir5)
Expand All @@ -61,7 +67,7 @@ GrapleGetExperimentJobResults(graplerURL, expId5)
#Experiment 6: A sweep experiment using using various distributions for generating ranges
#w/ post processing R-Filter(experimental feature)
simDir6="C:/ExpRoot/Exp6"
filterName = "Filter1.R"
filterName = "Filter2.R"
setwd(simDir6)
expId6<-GrapleRunExperimentJob(graplerURL, simDir6, filterName)
GrapleCheckExperimentCompletion(graplerURL, expId6)
Expand Down