Skip to content

Commit a6933ef

Browse files
authored
Merge pull request PecanProject#10 from ashiklom/custom-list
Pass additional customization list to `submit.workflow`
2 parents 09e43e6 + 81e9e8d commit a6933ef

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

R/submit.workflow.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
##' @param sensitivity.analysis Whether or not to perform a sensitivity analysis. Can also take
1515
##' a sensitivity setting object as input. Default: FALSE (logical or list)
1616
##' @param notes Additional notes that the user need to specify for the submitted workflow. Default: NULL
17+
##' @param workflow_list_mods List of additional changes to be applied to the
18+
##' workflow list. Passed to [utils::modifyList()]. Default = `list() (no changes)`.
1719
##' @return Response obtained from the `POST /api/workflows/` endpoint
1820
##' @author Tezan Sahu, Alexey Shiklomanov
1921
##' @export
@@ -27,7 +29,8 @@
2729
##' end_date="2003-12-31", inputs=list(met=list(id=99000000003)))
2830

2931
submit.workflow <- function(server, model_id, site_id, pfts, start_date, end_date, inputs, meta.analysis = list(),
30-
ensemble_size=1, sensitivity_variable = "NPP", sensitivity.analysis = FALSE, notes = NULL) {
32+
ensemble_size=1, sensitivity_variable = "NPP", sensitivity.analysis = FALSE, notes = NULL,
33+
workflow_list_mods = list()) {
3134
# Prepare the workflow based on the parameters set by user
3235
workflow <- list()
3336
workflow$pfts <- lapply(pfts, function(x) list(name = x))
@@ -80,6 +83,9 @@ submit.workflow <- function(server, model_id, site_id, pfts, start_date, end_dat
8083
workflow$info$notes <- notes
8184
}
8285

86+
# Apply any additional user changes (if any)
87+
workflow <- modifyList(workflow, workflow_list_mods)
88+
8389
# Submit the prepared workflow to the PEcAn API in XML format
8490
# NOTE: Use XML here because JSON doesn't like duplicate tags (which we use
8591
# for PFTs, among other things).

inst/run-test-list.R

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,21 @@ test_list <- read.csv("inst/integration-test-list.csv", comment.char = "#") %>%
4141
as_tibble() %>%
4242
# Only test models that are available on the target machine
4343
inner_join(models, c("model_name", "revision")) %>%
44-
mutate(start_date = if_else(is.na(start_date), default_start_date, as.character(start_date)),
45-
end_date = if_else(is.na(end_date), default_end_date, as.character(end_date)),
46-
# TODO: Add more inputs here
47-
inputs = pmap(., configure_inputs),
48-
pfts = strsplit(pfts, "|", fixed = TRUE))
44+
mutate(
45+
start_date = if_else(is.na(start_date), default_start_date, as.character(start_date)),
46+
end_date = if_else(is.na(end_date), default_end_date, as.character(end_date)),
47+
# TODO: Add more inputs here
48+
inputs = pmap(., configure_inputs),
49+
pfts = strsplit(pfts, "|", fixed = TRUE),
50+
# ED2-specific customizations
51+
workflow_list_mods = if_else(
52+
model_name == "ED2.2",
53+
list(list(model = list(phenol.scheme = 0,
54+
ed_misc = list(output_month = 12),
55+
edin = "ED2IN.r2.2.0"))),
56+
list(list())
57+
)
58+
)
4959

5060
test_runs <- test_list %>%
5161
select_if(colnames(.) %in% names(formals(submit.workflow))) %>%

man/submit.workflow.Rd

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)