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

Shifted convert.input.R from utils to DB #3026

Merged
merged 17 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from 13 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ see if you need to change any of these:
package the version that was provided with this release and the version that
is currently installed. Use it in scripts to record your system state for
reproducibility, or for debugging.
- Added a new function `unit_is_parseable` in PEcAn.utils to replace `udunits2::ud.is.parseable`.
(#3002; @nanu1605)
- Initial LDNDC model coupling

We are slowly change the license from NCSA opensource to BSD-3 to help with publishing PEcAn to CRAN.
Expand Down Expand Up @@ -62,6 +64,9 @@ convert data for a single PFT fixed (#1329, #2974, #2981)
- api is now open by default (was auth required in the past)
- Installation instructions updated in documentation
- PEcAn.assim.sequential is renamed to PEcAnAssimSequential
- `convert.input` is moved from PEcAn.utils to PEcAn.DB and renamed as `convert_input`.
This was needed to resolve a cyclic dependency between PEcAn.DB and PEcAn.utils.
(#3026; @nanu1605)

### Removed

Expand Down
7 changes: 5 additions & 2 deletions base/db/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: PEcAn.DB
Type: Package
Title: PEcAn Functions Used for Ecological Forecasts and Reanalysis
Version: 1.7.2
Version: 1.7.2.9000
Date: 2021-10-04
Authors@R: c(person("David", "LeBauer", role = c("aut", "cre"),
email = "[email protected]"),
Expand Down Expand Up @@ -49,16 +49,19 @@ Imports:
knitr,
lubridate,
magrittr,
methods,
ncdf4,
PEcAn.logger,
PEcAn.remote,
PEcAn.utils,
purrr,
R.utils,
RCurl,
rlang,
tibble,
tidyr,
units
units,
XML
Suggests:
bit64,
data.table,
Expand Down
1 change: 1 addition & 0 deletions base/db/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export(append.covariate)
export(assign.treatments)
export(bety2pecan)
export(betyConnect)
export(convert_input)
export(db.close)
export(db.exists)
export(db.getShowQueries)
Expand Down
3 changes: 3 additions & 0 deletions base/db/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* New functions `stamp_started` and `stamp_finished`, used to record the start
and end time of model runs in the database. Both used to live in
`PEcAn.remote` and were moved to resolve a circular dependency.
* New function `convert_input`, used to convert between formats while reusing
existing files where possible. It previously lived in package `PEcAn.utils`,
but was moved here to simplify dependencies. (#3026; @nanu1605)

# PEcAn.DB 1.7.2

Expand Down
94 changes: 46 additions & 48 deletions base/utils/R/convert.input.R → base/db/R/convert_input.R

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions base/db/R/insert_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ match_dbcols <- function(values, table, con, coerce_col_class = TRUE, drop = TRU
# Load one row to get column types
sql_row <- dplyr::tbl(con, table) %>% utils::head(1) %>% dplyr::collect()
sql_types <- purrr::map(sql_row, class) %>%
purrr::map_chr(1) %>%
.[use_cols]
purrr::map_chr(1)
sql_types <- sql_types[use_cols]
values_types <- purrr::map(values_sub, class) %>% purrr::map_chr(1)
type_mismatch <- sql_types != values_types
if (sum(type_mismatch) > 0) {
Expand All @@ -69,7 +69,7 @@ match_dbcols <- function(values, table, con, coerce_col_class = TRUE, drop = TRU
"Coercing local column types to match SQL."
)
# Coerce values data frame to these types
values_fixed <- purrr::map2_dfc(values_sub, sql_types, as)
values_fixed <- purrr::map2_dfc(values_sub, sql_types, methods::as)
}
} else {
values_fixed <- values_sub
Expand Down
38 changes: 19 additions & 19 deletions base/utils/man/convert.input.Rd → base/db/man/convert_input.Rd

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

1 change: 0 additions & 1 deletion base/utils/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Suggests:
data.table,
ggplot2,
MASS,
PEcAn.DB,
randtoolbox,
raster,
rjags,
Expand Down
7 changes: 7 additions & 0 deletions base/utils/NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# PEcAn.DB 1.7.2.9000

## Added

* Shifted `convert.input` function from `PEcAn.utils` to `PEcAn.DB` with a new name `convert_input`to remove circular dependency.
(#3026; @nanu1605)
* Added a stub function `convert.input`. (#3026; @nanu1605)
17 changes: 17 additions & 0 deletions base/utils/R/Defunct.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#' @title Defunct functions in PEcAn.utils
#' @description The functions listed below are defunct and have been removed from the package.
#' Calling them will produce a message indicating what function, if any, has replaced it.
#'
#' @name PEcAn.utils-defunct
#' @keywords internal
NULL


#' @rdname PEcAn.utils-defunct
#' @section `convert.input`: Use `PEcAn.DB::convert_input` instead.
#' @usage NULL
#' @aliases convert.input convert.input-defunct
#' @export
convert.input <- function(...){
.Defunct("PEcAn.DB::convert_input", package = NULL)
} # convert.input()
2 changes: 1 addition & 1 deletion base/utils/R/help.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
##'
##' @docType package
##' @name PEcAn
##' @aliases PECAn, pecan, package-pecan
##' @aliases PECAn pecan package-pecan
NULL
1 change: 1 addition & 0 deletions base/utils/R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ zero.bounded.density <- function(x, bw = "SJ", n = 1001) {
##' @export summarize.result
##' @usage summarize.result(result)
##' @importFrom rlang .data
##' @importFrom magrittr %>%
##' @author David LeBauer, Alexey Shiklomanov
summarize.result <- function(result) {
ans1 <- result %>%
Expand Down
4 changes: 2 additions & 2 deletions base/utils/man/PEcAn.Rd

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

16 changes: 16 additions & 0 deletions base/utils/man/PEcAn.utils-defunct.Rd

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

Loading