Last active
January 25, 2021 18:37
-
-
Save ashiklom/4dde4861be144489aaba05431ce24782 to your computer and use it in GitHub Desktop.
PEcAn API minimal example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rpecanapi) | |
library(httr) | |
library(magrittr, include.only = "%>%") | |
library(dplyr) | |
library(glue) | |
wfmessage <- function(wf) { | |
message(glue( | |
"Follow workflow status at:\n", | |
"http://localhost:8000/pecan/05-running.php?", | |
"workflowid={format(wf$workflow_id, scientific = FALSE)}&hostname=docker" | |
)) | |
} | |
## dbcon <- DBI::dbConnect( | |
## RPostgres::Postgres(), | |
## host = "localhost", | |
## dbname = "bety", | |
## user = "bety", | |
## password = "bety" | |
## ) | |
server <- connect("http://localhost:8000", "ashiklom", "admin") | |
ping(server) | |
model_id <- 1000000014 | |
testmod <- get.model(server, model_id) | |
# Willow creek | |
## site_id <- 676 | |
# Harvard Forest | |
site_id <- 646 | |
models <- GET(file.path(server$url, "api", "availableModels/"), | |
authenticate(server$user, server$password)) %>% | |
content() %>% | |
bind_rows() | |
sipnet_id <- models %>% | |
filter(model_name == "SIPNET") %>% | |
pull(model_id) | |
wf <- submit.workflow( | |
server, sipnet_id, site_id, | |
pfts = "temperate.coniferous", | |
start_date = "2012-06-01", | |
end_date = "2012-08-01", | |
inputs = list(met = list(source = "MERRA")) | |
) | |
wfmessage(wf) | |
ed_id <- models %>% | |
filter(model_name == "ED2.2") %>% | |
pull(model_id) | |
wf <- submit.workflow( | |
server, ed_id, site_id, | |
pfts = "temperate.Early_Hardwood", | |
start_date = "2012-01-01", | |
end_date = "2012-02-01", | |
inputs = list(met = list(source = "MERRA"), | |
lu = list(id = 294), | |
thsum = list(id = 295), | |
veg = list(id = 296), | |
soil = list(id = 297)), | |
workflow_list_mods = list(model = list( | |
phenol.scheme = 0, | |
ed_misc = list(output_month = 12), | |
edin = "ED2IN.r2.2.0" | |
)) | |
) | |
wfmessage(wf) | |
if (FALSE) { | |
l <- list(a = list(x = 5)) | |
settings <- PEcAn.settings::read.settings("zz-settings.xml") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rpecanapi) | |
library(httr) | |
library(magrittr, include.only = "%>%") | |
library(dplyr) | |
library(glue) | |
server <- connect("http://localhost:8000", "ashiklom", "admin") | |
# Willow creek | |
## site_id <- 676 | |
# Harvard Forest | |
site_id <- 646 | |
models <- GET(file.path(server$url, "api", "availableModels/"), | |
authenticate(server$user, server$password)) %>% | |
content() %>% | |
bind_rows() | |
model_id <- models %>% | |
filter(model_name == "SIPNET") %>% | |
pull(model_id) | |
wf <- submit.workflow( | |
server, model_id, site_id, | |
pfts = "temperate.coniferous", | |
start_date = "2012-06-01", | |
end_date = "2012-08-01", | |
inputs = list(met = list(source = "MERRA")) | |
) | |
message(glue( | |
"Follow workflow status at:\n", | |
"http://localhost:8000/pecan/05-running.php?", | |
"workflowid={format(wf$workflow_id, scientific = FALSE)}&hostname=docker" | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment