From b0710d33621206b01bfacbb34de77c3909f6fd55 Mon Sep 17 00:00:00 2001 From: Abhinav Pandey Date: Sun, 10 Mar 2024 11:55:58 +0530 Subject: [PATCH 1/4] Update server URLs in code --- R/connect.R | 2 +- R/download.input.R | 2 +- R/download.run.input.R | 2 +- R/download.run.output.R | 2 +- R/download.workflow.file.R | 2 +- R/get.format.R | 2 +- R/get.model.R | 2 +- R/get.pft.R | 2 +- R/get.run.R | 2 +- R/get.runs.R | 2 +- R/get.site.R | 2 +- R/get.status.R | 2 +- R/get.workflow.R | 2 +- R/get.workflow.status.R | 2 +- R/get.workflows.R | 2 +- R/ping.R | 2 +- R/plot_run_vars.R | 2 +- R/search.formats.R | 2 +- R/search.inputs.R | 2 +- R/search.models.R | 2 +- R/search.pfts.R | 2 +- R/search.sites.R | 2 +- R/submit.workflow.R | 2 +- R/submit.workflow.json.R | 2 +- R/submit.workflow.xml.R | 2 +- R/submit.workflows.csv.R | 2 +- README.md | 118 ++++++++++++++++++++---------- inst/permutation-test.R | 2 +- inst/run-test-list.R | 2 +- man/connect.Rd | 2 +- man/download.input.Rd | 2 +- man/download.run.input.Rd | 2 +- man/download.run.output.Rd | 2 +- man/download.workflow.file.Rd | 2 +- man/get.format.Rd | 2 +- man/get.model.Rd | 2 +- man/get.pft.Rd | 2 +- man/get.run.Rd | 2 +- man/get.runs.Rd | 2 +- man/get.site.Rd | 2 +- man/get.status.Rd | 2 +- man/get.workflow.Rd | 2 +- man/get.workflow.status.Rd | 2 +- man/get.workflows.Rd | 2 +- man/ping.Rd | 2 +- man/plot_run_vars.Rd | 2 +- man/search.formats.Rd | 2 +- man/search.inputs.Rd | 2 +- man/search.models.Rd | 2 +- man/search.pfts.Rd | 2 +- man/search.sites.Rd | 2 +- man/submit.workflow.Rd | 2 +- man/submit.workflow.json.Rd | 2 +- man/submit.workflow.xml.Rd | 2 +- man/submit.workflows.csv.Rd | 2 +- tests/testthat/setup_connection.R | 2 +- vignettes/rpecanapi.Rmd | 6 +- 57 files changed, 136 insertions(+), 98 deletions(-) diff --git a/R/connect.R b/R/connect.R index 1a16a1a..affd373 100644 --- a/R/connect.R +++ b/R/connect.R @@ -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) diff --git a/R/download.input.R b/R/download.input.R index 2009f97..2e7bd92 100644 --- a/R/download.input.R +++ b/R/download.input.R @@ -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') diff --git a/R/download.run.input.R b/R/download.run.input.R index c0f2b68..a27cc5a 100644 --- a/R/download.run.input.R +++ b/R/download.run.input.R @@ -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') diff --git a/R/download.run.output.R b/R/download.run.output.R index c73aaa6..b1fbcc8 100644 --- a/R/download.run.output.R +++ b/R/download.run.output.R @@ -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') diff --git a/R/download.workflow.file.R b/R/download.workflow.file.R index e0a63e1..5af221c 100644 --- a/R/download.workflow.file.R +++ b/R/download.workflow.file.R @@ -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') diff --git a/R/get.format.R b/R/get.format.R index 2c51a0d..6ead7d7 100644 --- a/R/get.format.R +++ b/R/get.format.R @@ -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) diff --git a/R/get.model.R b/R/get.model.R index 11f0786..15d8add 100644 --- a/R/get.model.R +++ b/R/get.model.R @@ -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) diff --git a/R/get.pft.R b/R/get.pft.R index 60ca291..506a5d6 100644 --- a/R/get.pft.R +++ b/R/get.pft.R @@ -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) diff --git a/R/get.run.R b/R/get.run.R index 2179a3a..60041d8 100644 --- a/R/get.run.R +++ b/R/get.run.R @@ -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) diff --git a/R/get.runs.R b/R/get.runs.R index 246488a..2a0ec9e 100644 --- a/R/get.runs.R +++ b/R/get.runs.R @@ -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) diff --git a/R/get.site.R b/R/get.site.R index 308061c..ce9c5bd 100644 --- a/R/get.site.R +++ b/R/get.site.R @@ -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 WillowCreek(US-WCr) site (id = 676) ##' res <- get.site(server, site_id=676) diff --git a/R/get.status.R b/R/get.status.R index 5074f64..56de893 100644 --- a/R/get.status.R +++ b/R/get.status.R @@ -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){ diff --git a/R/get.workflow.R b/R/get.workflow.R index 3a24841..76145b8 100644 --- a/R/get.workflow.R +++ b/R/get.workflow.R @@ -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) diff --git a/R/get.workflow.status.R b/R/get.workflow.status.R index 55fa109..d88af00 100644 --- a/R/get.workflow.status.R +++ b/R/get.workflow.status.R @@ -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) diff --git a/R/get.workflows.R b/R/get.workflows.R index 877bc26..d0cc2db 100644 --- a/R/get.workflows.R +++ b/R/get.workflows.R @@ -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) diff --git a/R/ping.R b/R/ping.R index 7de96dd..582f8f7 100644 --- a/R/ping.R +++ b/R/ping.R @@ -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){ diff --git a/R/plot_run_vars.R b/R/plot_run_vars.R index f81283f..f873d69 100644 --- a/R/plot_run_vars.R +++ b/R/plot_run_vars.R @@ -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") diff --git a/R/search.formats.R b/R/search.formats.R index d4cd3f6..5c8f16a 100644 --- a/R/search.formats.R +++ b/R/search.formats.R @@ -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) diff --git a/R/search.inputs.R b/R/search.inputs.R index 0fa3e45..3baeaa8 100644 --- a/R/search.inputs.R +++ b/R/search.inputs.R @@ -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) diff --git a/R/search.models.R b/R/search.models.R index e3681d6..2b33a04 100644 --- a/R/search.models.R +++ b/R/search.models.R @@ -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) diff --git a/R/search.pfts.R b/R/search.pfts.R index 996e945..60fee73 100644 --- a/R/search.pfts.R +++ b/R/search.pfts.R @@ -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) diff --git a/R/search.sites.R b/R/search.sites.R index cae2b57..112c17d 100644 --- a/R/search.sites.R +++ b/R/search.sites.R @@ -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) diff --git a/R/submit.workflow.R b/R/submit.workflow.R index 374e16d..33e6772 100644 --- a/R/submit.workflow.R +++ b/R/submit.workflow.R @@ -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 diff --git a/R/submit.workflow.json.R b/R/submit.workflow.json.R index b26d9fc..1f9946c 100644 --- a/R/submit.workflow.json.R +++ b/R/submit.workflow.json.R @@ -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){ diff --git a/R/submit.workflow.xml.R b/R/submit.workflow.xml.R index 30e6372..bb93561 100644 --- a/R/submit.workflow.xml.R +++ b/R/submit.workflow.xml.R @@ -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){ diff --git a/R/submit.workflows.csv.R b/R/submit.workflows.csv.R index 5e8f34a..8403aaa 100644 --- a/R/submit.workflows.csv.R +++ b/R/submit.workflows.csv.R @@ -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) { diff --git a/README.md b/README.md index f26fca0..60fa59b 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ This package allows users to get relevant information from the PEcAn database as ## Installation You can install the development version of `rpecanapi` from GitHub as follows: + ```R # install.packages("devtools") devtools::install_github("PecanProject/rpecanapi") @@ -19,7 +20,7 @@ devtools::install_github("PecanProject/rpecanapi") ## Usage -_The following snippets assume that the PEcAn RESTful API Server is running on `http://localhost:8000`. This can be replaced with any +_The following snippets assume that the PEcAn RESTful API Server is running on `http://pecan.localhost:80`. This can be replaced with any other appropriate PEcAn Server URL._ - [Getting Started](#getting-started) @@ -36,13 +37,15 @@ other appropriate PEcAn Server URL._ ### Getting Started #### Load `rpecanapi` & Create the Server Object + ```R library(rpecanapi) -server <- connect(url="http://localhost:8000", username="carya", password="illinois") +server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois") ``` #### Ping the PEcAn API Server + ```R ping(server) @@ -52,44 +55,50 @@ ping(server) #> $response #> [1] "pong" ``` + #### Get General Information about the Server & PEcAn Version + ```R -get.status(server) +# get.status(server) -#> $pecan_details$version -#> [1] "1.7.0" +# $host_details +# $host_details$hostid +# [1] 99 -#> $pecan_details$branch -#> [1] "develop" +# $host_details$hostname +# [1] "" -#> $pecan_details$gitsha1 -#> [1] "unknown" +# $host_details$start +# [1] 9.9e+10 -#> $host_details$hostid -#> [1] 99 +# $host_details$end +# [1] 1e+11 -#> $host_details$hostname -#> [1] "" +# $host_details$sync_url +# [1] "" -#> $host_details$start -#> [1] 99000000000 +# $host_details$sync_contact +# [1] "" -#> $host_details$end -#> [1] 99999999999 +# $host_details$authentication_required +# [1] "FALSE" -#> $host_details$sync_url -#> [1] "" -#> $host_details$sync_contact -#> [1] "" +# $pecan_details +# $pecan_details$version +# [1] "develop" -#> $host_details$authentication_required -#> "TRUE" +# $pecan_details$branch +# [1] "develop" + +# $pecan_details$gitsha1 +# [1] "48a3b259fd03512c145b4d6eb387467e56ab49b4" ``` ### Get Information about PEcAn Models -#### Search for PEcAn Model(s): +#### Search for PEcAn Model(s) + ```R search.models(server, model_name='sip', revision='r') @@ -102,7 +111,8 @@ search.models(server, model_name='sip', revision='r') #> [1] 2 ``` -#### Get the details of a PEcAn Model: +#### Get the details of a PEcAn Model + ```R get.model(server, model_id='1000000014') @@ -126,9 +136,11 @@ get.model(server, model_id='1000000014') #> 1 met TRUE #> 2 poolinitcond FALSE ``` + ### Get Information about PEcAn Sites -#### Search for PEcAn Site(s): +#### Search for PEcAn Site(s) + ```R search.sites(server, sitename='willow') @@ -144,7 +156,8 @@ search.sites(server, sitename='willow') #> [1] 5 ``` -#### Get the details of a PEcAn Site: +#### Get the details of a PEcAn Site + ```R get.site(server, site_id='676') @@ -193,9 +206,11 @@ get.site(server, site_id='676') #> $time_zone #> [1] "America/Chicago" ``` + ### Get Information about PEcAn PFTs (Plant Functional Types) -#### Search for PEcAn PFT(s): +#### Search for PEcAn PFT(s) + ```R search.pfts(server, pft_name='deciduous', model_type='sipnet') @@ -213,7 +228,8 @@ search.pfts(server, pft_name='deciduous', model_type='sipnet') #> [1] 7 ``` -#### Get the details of a PEcAn PFT: +#### Get the details of a PEcAn PFT + ```R get.pft(server, pft_id='2000000045') @@ -232,9 +248,11 @@ get.pft(server, pft_id='2000000045') #> $pft_type #> [1] "plant" ``` + ### Get Information about PEcAn Formats -#### Search for PEcAn Formats: +#### Search for PEcAn Formats + ```R search.formats(server, format_name="ameriflux", mimetype="netcdf") @@ -247,7 +265,8 @@ search.formats(server, format_name="ameriflux", mimetype="netcdf") #> [1] 2 ``` -#### Get details about a PEcAn Format: +#### Get details about a PEcAn Format + ```R get.format(server, format_id=38) @@ -275,7 +294,8 @@ get.format(server, format_id=38) ### Get Information about PEcAn Inputs -#### Search for PEcAn Inputs: +#### Search for PEcAn Inputs + ```R search.inputs(server, model_id=1000000014, site_id=772, host_id=99000000001) @@ -291,15 +311,18 @@ search.inputs(server, model_id=1000000014, site_id=772, host_id=99000000001) #> [1] 2 ``` -#### Download a PEcAn Input File: +#### Download a PEcAn Input File + ```R download.input(server, input_id=99000000003, save_as="niwot.clim.local") ``` + _This will download the requested input file & save it as `niwot.clim.local`_ ### Get Information about PEcAn Workflows -#### Get list of PEcAn Workflows: +#### Get list of PEcAn Workflows + ```R get.workflows(server, model_id='1000000022', site_id='676') @@ -315,7 +338,8 @@ get.workflows(server, model_id='1000000022', site_id='676') #> [1] 5 ``` -#### Get details about a PEcAn Workflow: +#### Get details about a PEcAn Workflow + ```R get.workflow(server, workflow_id='99000000031') @@ -382,6 +406,7 @@ get.workflow(server, workflow_id='99000000031') ### Submit a PEcAn Workflow for Execution #### Submit a workflow directly using user-specified parameters + ```R submit.workflow( server, @@ -403,6 +428,7 @@ submit.workflow( ``` #### Submit a workflow as an XML file + _This assumes the presence of an XML file `test.xml` containing the specifications of the workflow._ ```R @@ -415,7 +441,9 @@ submit.workflow.xml(server, xmlFile='test.xml') ``` #### Submit a workflow as a JSON file + _This assumes the presence of a JSON file `test.json` containing the specifications of the workflow._ + ```R submit.workflow.json(server, xmlFile='test.json') #> $workflow_id @@ -426,6 +454,7 @@ submit.workflow.json(server, xmlFile='test.json') ``` #### Submit a set of workflows specified as a CSV file + _This assumes the presence of a CSV file `test.csv` containing the specifications of the set of workflows._ _Columns: `model` `revision` `met` `site_id` `pft` `start_date` `end_date` `sensitivity` `ensemble` `comment`_ @@ -451,6 +480,7 @@ submit.workflows.csv(server, csvFile='test.csv') ### Get Information about PEcAn Runs #### Get list of Runs belonging to a PEcAn Workflow + ```R get.runs(server, workflow_id='1000009172') @@ -467,7 +497,7 @@ get.runs(server, workflow_id='1000009172') #> [1] 50 #> $next_page -#> [1] "http://localhost:8000/api/runs/?workflow_id=1000009172&offset=50&limit=50" +#> [1] "http://pecan.localhost:80/api/runs/?workflow_id=1000009172&offset=50&limit=50" ``` #### Get details about a PEcAn Run @@ -535,9 +565,10 @@ get.run(server, run_id='99000000282') #> ... ``` + ### Plots & File Downloads for Workflows & Runs -#### Plot the desired variables from the results of a PEcAn Run: +#### Plot the desired variables from the results of a PEcAn Run ```R plot_run_vars( @@ -548,24 +579,31 @@ plot_run_vars( x_var="SoilResp" ) ``` + _This will produce a `plot.png` file containing the requested plot_ -#### Download an Input File for a Run: +#### Download an Input File for a Run + ```R download.run.input(server, run_id=99000000283, filename="sipnet.in", save_as="sipnet.in.local") ``` + _This will download the requested input file & save it as `sipnet.in.local`_ -#### Download an Output File for a Run: +#### Download an Output File for a Run + ```R download.run.output(server, run_id=99000000283, filename="2002.nc", save_as="local.2002.nc") ``` + _This will download the requested output file & save it as `local.2002.nc`_ -#### Download a File for a Workflow: +#### Download a File for a Workflow + ```R download.workflow.file(server, workflow_id=99000000031, filename="pecan.xml", save_as="local.pecan.xml") ``` + _This will download the requested file & save it as `local.pecan.xml`_ *** diff --git a/inst/permutation-test.R b/inst/permutation-test.R index e8a6962..02deec0 100644 --- a/inst/permutation-test.R +++ b/inst/permutation-test.R @@ -9,7 +9,7 @@ library(glue) argv <- commandArgs(trailingOnly = TRUE) # Modify for your target machine and authentication -server <- connect("http://localhost:8000", "ashiklom", "admin") +server <- connect("http://pecan.localhost:80", "ashiklom", "admin") met_source <- c("CRUNCEP", "AmerifluxLBL") startdate <- "2004-01-01" diff --git a/inst/run-test-list.R b/inst/run-test-list.R index 8de856c..85d02d5 100644 --- a/inst/run-test-list.R +++ b/inst/run-test-list.R @@ -7,7 +7,7 @@ library(httr) library(glue) # Modify for your target machine and authentication -server <- connect("http://localhost:8000", "ashiklom", "admin") +server <- connect("http://pecan.localhost:80", "ashiklom", "admin") # List all available models models <- GET( diff --git a/man/connect.Rd b/man/connect.Rd index a0d6fde..f833ba3 100644 --- a/man/connect.Rd +++ b/man/connect.Rd @@ -24,5 +24,5 @@ Currently, there is no validation. In future, we may validate the username-passw pair by hitting the appropriate API endpoint } \examples{ -server <- connect(url="http://localhost:8000", username="carya", password="illinois") +server <- connect(url="http://pecan.localhost:80", username="carya", password="illinois") } diff --git a/man/download.input.Rd b/man/download.input.Rd index b7f41c3..18aee97 100644 --- a/man/download.input.Rd +++ b/man/download.input.Rd @@ -24,7 +24,7 @@ Downloads & saves the desired input file. Hits the \verb{/api/inputs/\{input_id\}} API endpoint } \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') diff --git a/man/download.run.input.Rd b/man/download.run.input.Rd index 716bf53..ebd4d48 100644 --- a/man/download.run.input.Rd +++ b/man/download.run.input.Rd @@ -24,7 +24,7 @@ Downloads & saves the desired input file for a run. Hits the \verb{/api/run/\{run_id\}/input/\{filename\}} API endpoint } \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') diff --git a/man/download.run.output.Rd b/man/download.run.output.Rd index 1cf38e9..739a229 100644 --- a/man/download.run.output.Rd +++ b/man/download.run.output.Rd @@ -24,7 +24,7 @@ Downloads & saves the desired output file for a run. Hits the \verb{/api/run/\{run_id\}/output/\{filename\}} API endpoint } \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') diff --git a/man/download.workflow.file.Rd b/man/download.workflow.file.Rd index d31e588..ab00ec5 100644 --- a/man/download.workflow.file.Rd +++ b/man/download.workflow.file.Rd @@ -24,7 +24,7 @@ Downloads & saves the desired file for a workflow. Hits the \verb{/api/workflows/\{id\}/file/\{filename\}} API endpoint } \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') diff --git a/man/get.format.Rd b/man/get.format.Rd index df0d592..2903a85 100644 --- a/man/get.format.Rd +++ b/man/get.format.Rd @@ -19,7 +19,7 @@ Get details of PEcAn Format from the database using format id. Hits the \verb{/api/formats/\{format_id\}} API endpoint. } \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) diff --git a/man/get.model.Rd b/man/get.model.Rd index 6acf148..1b5a1be 100644 --- a/man/get.model.Rd +++ b/man/get.model.Rd @@ -19,7 +19,7 @@ Get details of PEcAn Model from the database using model id. Hits the \verb{/api/models/\{model_id\}} API endpoint. } \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) diff --git a/man/get.pft.Rd b/man/get.pft.Rd index 2ab34ad..5120b05 100644 --- a/man/get.pft.Rd +++ b/man/get.pft.Rd @@ -19,7 +19,7 @@ Get details of PEcAn PFT from the database using PFT id. Hits the \verb{/api/pfts/\{pft_id\}} API endpoint. } \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) diff --git a/man/get.run.Rd b/man/get.run.Rd index f94b8b0..1b795e7 100644 --- a/man/get.run.Rd +++ b/man/get.run.Rd @@ -19,7 +19,7 @@ Obtain the details of a details of a specified PEcAn run. Hits the \verb{/api/run/\{id\}} API endpoint } \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) diff --git a/man/get.runs.Rd b/man/get.runs.Rd index 74e4196..c45ce1d 100644 --- a/man/get.runs.Rd +++ b/man/get.runs.Rd @@ -23,7 +23,7 @@ Retrive a list of all PEcAn runs from the database that belong to a specific workflow } \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) diff --git a/man/get.site.Rd b/man/get.site.Rd index 09e01f9..f88fee8 100644 --- a/man/get.site.Rd +++ b/man/get.site.Rd @@ -19,7 +19,7 @@ Get details of PEcAn Site from the database using site id. Hits the \verb{/api/sites/\{site_id\}} API endpoint. } \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) diff --git a/man/get.status.Rd b/man/get.status.Rd index b6b09b9..8124824 100644 --- a/man/get.status.Rd +++ b/man/get.status.Rd @@ -17,7 +17,7 @@ Obtain general information about PEcAn & the details of the database host Hits the \verb{/api/status} API endpoint } \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) } \author{ diff --git a/man/get.workflow.Rd b/man/get.workflow.Rd index 963bfdd..736dab1 100644 --- a/man/get.workflow.Rd +++ b/man/get.workflow.Rd @@ -19,7 +19,7 @@ Obtain the details of a particular PEcAn workflow by supplying its ID. Hits the \verb{/api/workflows/\{id\}} API endpoint } \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) diff --git a/man/get.workflow.status.Rd b/man/get.workflow.status.Rd index 83db8a3..d17c102 100644 --- a/man/get.workflow.status.Rd +++ b/man/get.workflow.status.Rd @@ -19,7 +19,7 @@ Obtain the status of a particular PEcAn workflow by supplying its ID. Hits the \verb{/api/workflows/\{id\}/status} API endpoint } \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) diff --git a/man/get.workflows.Rd b/man/get.workflows.Rd index f27cc09..2d558f0 100644 --- a/man/get.workflows.Rd +++ b/man/get.workflows.Rd @@ -27,7 +27,7 @@ about specific workflows. Hits the \verb{/api/workflows/} API endpoint with relevant query parameters } \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) diff --git a/man/ping.Rd b/man/ping.Rd index 566862d..c2695f1 100644 --- a/man/ping.Rd +++ b/man/ping.Rd @@ -17,7 +17,7 @@ Pings the PEcAn API server (using the URL passed in the server object) to see if it is live or not. Hits the \verb{/api/ping} API endpoint } \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) } \author{ diff --git a/man/plot_run_vars.Rd b/man/plot_run_vars.Rd index 36f1efa..7e65fc2 100644 --- a/man/plot_run_vars.Rd +++ b/man/plot_run_vars.Rd @@ -40,7 +40,7 @@ Plot the desired variables from the results of a PEcAn run. Hits the \verb{/api/run/\{run_id\}/graph/\{year\}/\{y_var\}} API endpoint } \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") diff --git a/man/search.formats.Rd b/man/search.formats.Rd index 96100b5..349d998 100644 --- a/man/search.formats.Rd +++ b/man/search.formats.Rd @@ -24,7 +24,7 @@ format_name & mimetype Hits the \verb{/api/formats/} API endpoint with relevant query parameters } \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) diff --git a/man/search.inputs.Rd b/man/search.inputs.Rd index dc8c6df..5c67eb3 100644 --- a/man/search.inputs.Rd +++ b/man/search.inputs.Rd @@ -38,7 +38,7 @@ model_id & site_id Hits the \verb{/api/inputs/} API endpoint with relevant query parameters } \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) diff --git a/man/search.models.Rd b/man/search.models.Rd index 08ecaf0..8946183 100644 --- a/man/search.models.Rd +++ b/man/search.models.Rd @@ -24,7 +24,7 @@ model_name & revision. Hits the \verb{/api/models/} API endpoint with relevant query parameters } \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) diff --git a/man/search.pfts.Rd b/man/search.pfts.Rd index 831fd31..0f591db 100644 --- a/man/search.pfts.Rd +++ b/man/search.pfts.Rd @@ -33,7 +33,7 @@ PFT name, type & model type. Hits the \verb{/api/pfts/} API endpoint with relevant query parameters } \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) diff --git a/man/search.sites.Rd b/man/search.sites.Rd index a35dfdc..0b1f51b 100644 --- a/man/search.sites.Rd +++ b/man/search.sites.Rd @@ -22,7 +22,7 @@ sitename. Hits the \verb{/api/sites/} API endpoint with relevant query parameters } \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) diff --git a/man/submit.workflow.Rd b/man/submit.workflow.Rd index c5945f4..0e40dfe 100644 --- a/man/submit.workflow.Rd +++ b/man/submit.workflow.Rd @@ -58,7 +58,7 @@ Submit a PEcAn workflow using various user-defined parameters Hits the \verb{POST /api/workflows/} API endpoint. } \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 diff --git a/man/submit.workflow.json.Rd b/man/submit.workflow.json.Rd index 8ad2b7a..3bae46a 100644 --- a/man/submit.workflow.json.Rd +++ b/man/submit.workflow.json.Rd @@ -19,7 +19,7 @@ Submit a JSON file as a PEcAn workflow. Hits the \verb{POST /api/workflows/} API endpoint } \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") } \author{ diff --git a/man/submit.workflow.xml.Rd b/man/submit.workflow.xml.Rd index 8e03644..535d981 100644 --- a/man/submit.workflow.xml.Rd +++ b/man/submit.workflow.xml.Rd @@ -19,7 +19,7 @@ Submit an XML file as a PEcAn workflow. Hits the \verb{POST /api/workflows/} API endpoint } \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") } \author{ diff --git a/man/submit.workflows.csv.Rd b/man/submit.workflows.csv.Rd index 673c991..b10ab86 100644 --- a/man/submit.workflows.csv.Rd +++ b/man/submit.workflows.csv.Rd @@ -21,7 +21,7 @@ Columns: model revision met site_id pft start_date end_date sensitivity Each row corresponds to one workflow to be submitted } \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") } \author{ diff --git a/tests/testthat/setup_connection.R b/tests/testthat/setup_connection.R index fe5c9db..c268ff8 100644 --- a/tests/testthat/setup_connection.R +++ b/tests/testthat/setup_connection.R @@ -1,3 +1,3 @@ set.server <- function(username="carya", password="illinois"){ - return(connect("http://localhost:8000", username, password)) + return(connect("http://pecan.localhost:80", username, password)) } \ No newline at end of file diff --git a/vignettes/rpecanapi.Rmd b/vignettes/rpecanapi.Rmd index 15ab503..71ae03e 100644 --- a/vignettes/rpecanapi.Rmd +++ b/vignettes/rpecanapi.Rmd @@ -38,13 +38,13 @@ This vignette covers the following major sections: ## Initial Setup {#pecanapi-setup} This tutorial assumes you are running a Dockerized instance of PEcAn on your local machine (hostname `localhost`, port 8000). -To check this, open a browser and try to access `http://localhost:8000`. +To check this, open a browser and try to access `http://pecan.localhost:80`. If you are trying to access a remote instance of PEcAn, you will need to substitute the hostname and port accordingly. We first create a server object with the appropriate credentials for authentication. ```{r, eval = FALSE} -server <- connect("http://localhost:8000", username = "carya", password = "illinois") +server <- connect("http://pecan.localhost:80", username = "carya", password = "illinois") ``` The rest of this tutorial assumes that you are using this same server object (`server`). @@ -297,7 +297,7 @@ download.workflow.file(server, workflow_id = '99000000001', filename = "pecan.CO This downloads the `pecan.CONFIG.xml` file from the server for the mentioned workflow & saves it locally using the same file name (because the `save_as` parameter is set to default value). All of PEcAn's outputs as well as its database files (`dbfiles`) can also be accessed remotely via the THREDDS data server. -You can explore these files by browsing to `localhost:8000/thredds/` in a browser (substituting hostname and port, accordingly). +You can explore these files by browsing to `pecan.localhost:80/thredds/` in a browser (substituting hostname and port, accordingly). Similarly, one can also fetch basic informtion about runs belonging to a workflow along with details for a particlar workflow: From 9cae10c47230b95b9001862c8251694e00b541cf Mon Sep 17 00:00:00 2001 From: Abhinav Pandey Date: Mon, 11 Mar 2024 00:28:00 +0530 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60fa59b..3922a6b 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ ping(server) #### Get General Information about the Server & PEcAn Version ```R -# get.status(server) +get.status(server) # $host_details # $host_details$hostid From 67549f606587ee1c7e8e03e4d8d9465902803cbc Mon Sep 17 00:00:00 2001 From: Abhinav Pandey Date: Thu, 21 Mar 2024 11:21:08 +0530 Subject: [PATCH 3/4] Update pkgdown.yml As suggested by Michael : "the version needs to be updated from @master to @v2. The @master branch was renames @main but @v2 is the current recommended stable branch" --- .github/workflows/pkgdown.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pkgdown.yml b/.github/workflows/pkgdown.yml index 4c26c04..2c707d9 100644 --- a/.github/workflows/pkgdown.yml +++ b/.github/workflows/pkgdown.yml @@ -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} @@ -62,4 +62,4 @@ jobs: shell: Rscript {0} run: | pkgdown::deploy_to_branch(new_process = FALSE) - \ No newline at end of file + From c39cf7ede531c2ff1f6c01d0438e46d23fd1a878 Mon Sep 17 00:00:00 2001 From: Abhinav Pandey Date: Sun, 24 Mar 2024 17:33:20 +0530 Subject: [PATCH 4/4] Testing CI with linting changes --- R/get.site.R | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/R/get.site.R b/R/get.site.R index ce9c5bd..2d778cd 100644 --- a/R/get.site.R +++ b/R/get.site.R @@ -2,30 +2,29 @@ ##' 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://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) } }, @@ -33,21 +32,17 @@ get.site <- function(server, site_id){ 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") } }