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

Fixed some global variables in PEcAn.DB package #2971

Merged
merged 20 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/db/R/get.trait.data.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ get.trait.data <- function(pfts, modeltype, dbfiles, database, forceupdate,
# `query_priors`, but haven't done so yet because that requires
# prepared statements and therefore requires the Postgres driver.
all_priors_list <- lapply(format(pft_ids, scientific = FALSE), query.priors,
con = dbcon, trstr = trait.names)
con = dbcon, trstr = trait.names, update = settings$db$update)
nanu1605 marked this conversation as resolved.
Show resolved Hide resolved
trait.names <- unique(unlist(lapply(all_priors_list, rownames)))
# Eventually, can replace with this:
# all_priors <- query_priors(pfts, params = database)
Expand Down
2 changes: 1 addition & 1 deletion base/db/R/get.trait.data.pft.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ get.trait.data.pft <- function(pft, modeltype, dbfiles, dbcon, trait.names,
dplyr::mutate_if(is.character, ~dplyr::na_if(., ""))

# get the priors
prior.distns <- PEcAn.DB::query.priors(pft = pftid, trstr = PEcAn.utils::vecpaste(trait.names), con = dbcon)
prior.distns <- PEcAn.DB::query.priors(pft = pftid, trstr = PEcAn.utils::vecpaste(trait.names), con = dbcon, update = settings$db$update)
nanu1605 marked this conversation as resolved.
Show resolved Hide resolved
prior.distns <- prior.distns[which(!rownames(prior.distns) %in% names(pft$constants)),]
traits <- rownames(prior.distns)

Expand Down
5 changes: 3 additions & 2 deletions base/db/R/query.prior.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
##' @param con Database connection object.
##' @param ... Optional arguments for connecting to database (e.g.
##' password, user name, database).
##' @param update
nanu1605 marked this conversation as resolved.
Show resolved Hide resolved
##'
##' @return `data.frame` of priors for each trait and the given PFT.
##' @export query.priors
Expand All @@ -31,7 +32,7 @@
##' con <- db.open(...)
##' query.priors("ebifarm.pavi", c("SLA", "Vcmax", "leaf_width"), con = con)
##' }
query.priors <- function(pft, trstr = NULL, con = NULL, ...){
query.priors <- function(pft, trstr = NULL, con = NULL, update, ...){
nanu1605 marked this conversation as resolved.
Show resolved Hide resolved

if (inherits(pft, "integer64")) {
# Convert to character with correct representation
Expand All @@ -50,7 +51,7 @@ query.priors <- function(pft, trstr = NULL, con = NULL, ...){
"`settings` object not found. Unable to connect to database."
)
}
params <- settings[[c("database", "bety")]]
params <- update[[c("database", "bety")]]
nanu1605 marked this conversation as resolved.
Show resolved Hide resolved
}
con <- db.open(params)
on.exit(db.close(con), add = TRUE)
Expand Down
4 changes: 3 additions & 1 deletion base/db/man/query.priors.Rd

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