Skip to content

Commit

Permalink
Merge pull request #22 from Sweetdevil144/master
Browse files Browse the repository at this point in the history
Update server URLs in code
  • Loading branch information
mdietze committed Apr 1, 2024
2 parents 362f289 + 7bee1a5 commit 8c000c4
Show file tree
Hide file tree
Showing 58 changed files with 151 additions and 118 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master
- uses: r-lib/actions/setup-r@v2

- uses: r-lib/actions/setup-pandoc@master
- uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
shell: Rscript {0}
Expand Down Expand Up @@ -62,4 +62,4 @@ jobs:
shell: Rscript {0}
run: |
pkgdown::deploy_to_branch(new_process = FALSE)
2 changes: 1 addition & 1 deletion R/connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
##' @return A server object that can be passed into other functions for making requests to the PEcAn API
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")

connect <- function(url, username=NULL, password=NULL){
res <- list(url=sub('^/|/$','',url), username=username, password=password)
Expand Down
2 changes: 1 addition & 1 deletion R/download.input.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Download the 'niwot.clim' file (id = 99000000003)
##' download.input(server, input_id='99000000003', save_as='local.niwot.clim')
Expand Down
2 changes: 1 addition & 1 deletion R/download.run.input.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Download the 'sipnet.clim' input for the run with id = '99000000282'
##' download.run.input(server, run_id=99000000282, filename='sipnet.clim', save_as='test.sipnet.clim')
Expand Down
2 changes: 1 addition & 1 deletion R/download.run.output.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Download the 'README.txt' output for the run with id = '99000000282'
##' download.run.output(server, run_id=99000000282, filename='README.txt', save_as='test.README.txt')
Expand Down
2 changes: 1 addition & 1 deletion R/download.workflow.file.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Download the 'ensemble.ts.99000000017.NPP.2002.2002.Rdata' output file for the workflow with id = 99000000031
##' download.workflow.file(server, workflow_id=99000000031, filename='ensemble.ts.99000000017.NPP.2002.2002.Rdata')
Expand Down
2 changes: 1 addition & 1 deletion R/get.format.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of the Ameriflux.level4.h format (id = 19)
##' res <- get.format(server, format_id=19)
Expand Down
2 changes: 1 addition & 1 deletion R/get.model.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of the SIPNET ssr model (id = 1000000022)
##' res <- get.model(server, model_id=1000000022)
Expand Down
2 changes: 1 addition & 1 deletion R/get.pft.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of the temperate.deciduous PFT (id = 41)
##' res <- get.pft(server, pft_id=41)
Expand Down
2 changes: 1 addition & 1 deletion R/get.run.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of run with id = '1002042201'
##' res <- get.run(server, 1002042201)
Expand Down
2 changes: 1 addition & 1 deletion R/get.runs.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of all runs for the workflow with ID '1000009172'
##' res <- get.runs(server, workflow_id=1000009172)
Expand Down
33 changes: 14 additions & 19 deletions R/get.site.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,47 @@
##' Hits the `/api/sites/{site_id}` API endpoint.
##' @name get.site
##' @title Get details of PEcAn Site from the database using site id
##' @param server Server object obtained using the connect() function
##' @param server Server object obtained using the connect() function
##' @param site_id ID of the model to retrieve
##' @return Response obtained from the `/api/sites/{site_id}` endpoint
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##'
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of the WillowCreek(US-WCr) site (id = 676)
##' res <- get.site(server, site_id=676)

get.site <- function(server, site_id){
get.site <- function(server, site_id) {
res <- NULL
tryCatch(
expr = {
url <- paste0(server$url, "/api/sites/", site_id)
if(! is.null(server$username) && ! is.null(server$password)){

if (!is.null(server$username) && !is.null(server$password)) {
res <- httr::GET(
url,
httr::authenticate(server$username, server$password)
)
}
else{
} else {
res <- httr::GET(url)
}
},
error = function(e) {
message("Sorry! Server not responding.")
}
)
if(! is.null(res)) {
if(res$status_code == 200){

if (!is.null(res)) {
if (res$status_code == 200) {
return(jsonlite::fromJSON(rawToChar(res$content)))
}
else if(res$status_code == 401){
} else if (res$status_code == 401) {
stop("Invalid credentials")
}
else if(res$status_code == 404){
} else if (res$status_code == 404) {
stop("Site not found")
}
else if(res$status_code == 500){
} else if (res$status_code == 500) {
stop("Internal server error")
}
else{
} else {
stop("Unidentified error")
}
}
Expand Down
2 changes: 1 addition & 1 deletion R/get.status.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##' res <- get.status(server)

get.status <- function(server){
Expand Down
2 changes: 1 addition & 1 deletion R/get.workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of workflow with id = '1000009172'
##' res <- get.workflow(server, workflow_id=1000009172)
Expand Down
2 changes: 1 addition & 1 deletion R/get.workflow.status.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of workflow with id = '1000009172'
##' res <- get.workflow.status(server, workflow_id=1000009172)
Expand Down
2 changes: 1 addition & 1 deletion R/get.workflows.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get list of all workflows
##' res1 <- get.workflows(server)
Expand Down
2 changes: 1 addition & 1 deletion R/ping.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##' res <- ping(server)

ping <- function(server){
Expand Down
2 changes: 1 addition & 1 deletion R/plot_run_vars.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Plot the Gross Primary Productivity vs Time for the run with ID '99000000282' for the year 2002
##' plot_run_vars(server, run_id=99000000282, year=2002, y_var="GPP")
Expand Down
2 changes: 1 addition & 1 deletion R/search.formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of all formats
##' res1 <- search.formats(server)
Expand Down
2 changes: 1 addition & 1 deletion R/search.inputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of all inputs
##' res1 <- search.inputs(server)
Expand Down
2 changes: 1 addition & 1 deletion R/search.models.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of all models
##' res1 <- search.models(server)
Expand Down
2 changes: 1 addition & 1 deletion R/search.pfts.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of all PFTs
##' res1 <- search.pfts(server)
Expand Down
2 changes: 1 addition & 1 deletion R/search.sites.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Get details of all sites
##' res1 <- search.sites(server)
Expand Down
2 changes: 1 addition & 1 deletion R/submit.workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
##' @author Tezan Sahu, Alexey Shiklomanov
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##'
##' # Submit a workflow with the SIPNET r136 model (id = 1000000014) for Niwot Ridge site (id = 772) with
##' # PFT as 'temperate.coniferous' starting from 01-01-2002 to 31-12-2003 using the input met data with
Expand Down
2 changes: 1 addition & 1 deletion R/submit.workflow.json.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##' res <- submit.workflow.json(server, "api.sipnet.json")

submit.workflow.json <- function(server, jsonFile){
Expand Down
2 changes: 1 addition & 1 deletion R/submit.workflow.xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##' res <- submit.workflow.xml(server, "api.sipnet.xml")

submit.workflow.xml <- function(server, xmlFile){
Expand Down
2 changes: 1 addition & 1 deletion R/submit.workflows.csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
##' @author Tezan Sahu
##' @export
##' @examples
##' server <- connect(url="http://localhost:8000", username="carya", password="illinois")
##' server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois")
##' res <- submit.workflows.csv(server, "default_tests.csv")

submit.workflows.csv <- function(server, csvFile) {
Expand Down
Loading

0 comments on commit 8c000c4

Please sign in to comment.