Skip to content

Commit

Permalink
Merge pull request #120 from RobLBaker/main
Browse files Browse the repository at this point in the history
Increment DPchecker version
  • Loading branch information
RobLBaker authored Dec 21, 2023
2 parents b8845db + d1912b1 commit ccec214
Show file tree
Hide file tree
Showing 167 changed files with 861 additions and 324 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: DPchecker
Title: Checks Data Packages for Congruence
Version: 0.3.2
Version: 0.3.3
Authors@R: c(
person("Rob", "Baker", email = "robert_baker@nps.gov", role = c("cre", "aut"), comment = c(ORCID = "0000-0001-7591-5035")),
person(c("Sarah", "E."), "Wright", email = "sarah_wright@nps.gov", role = "aut"),
Expand Down Expand Up @@ -33,7 +33,8 @@ Imports:
httr,
jsonlite,
stats,
QCkit
QCkit,
lifecycle
Remotes:
https://github.com/NCEAS/arcticdatautils,
https://github.com/nationalparkservice/QCkit
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ export(test_valid_fieldnames)
export(test_valid_filenames)
export(test_validate_schema)
importFrom(QCkit,convert_datetime_format)
importFrom(lifecycle,deprecated)
importFrom(magrittr,"%>%")
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Bug fixes for `test_date_range()` and `test_dates_parse()`.
* Adjusted `test_datatable_urls()` and `test_datatable_urls_doi()` so that they work properly when there are no data table urls present in metadata.
* Move convert_datetime_format to QCkit; add QCkit as re-export to DPchecker
* Updated tabular_data_congruence.R for speed and stability as per codefactor suggests

# DPchecker 0.3.2

Expand Down
1 change: 1 addition & 0 deletions R/DPchecker-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"_PACKAGE"

## usethis namespace: start
#' @importFrom lifecycle deprecated
#' @importFrom magrittr %>%
## usethis namespace: end
NULL
32 changes: 25 additions & 7 deletions R/tabular_data_congruence.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ test_validate_schema <- function(metadata = load_metadata(here::here())) {
cli::cli_inform(c("v" = "Your metadata is schema valid."))
} else {
attribs <- attributes(val)
issues <- c()
issues <- NULL
if ("errors" %in% names(attribs)) {
names(attribs$errors) <- rep("x", length(attribs$errors))
issues <- c(issues, attribs$errors)
Expand Down Expand Up @@ -703,7 +703,7 @@ test_dates_parse <- function(directory = here::here(),
# Check if temporal coverage info is complete. Throw a warning if it's missing entirely and an error if it's only partially complete.
# The logic being that maybe there's a scenario where temporal coverage isn't relevant to the dataset at all, but if it has date/time info, it has to have both a start and end.
if (missing_temporal) {
cli::cli_warn(c("!" = "Could not check date range. Metadata does not contain temporal coverage information."))
cli::cli_warn(c("!" = "Could not check date formats. Metadata does not contain temporal coverage information."))
return(invisible(metadata))
}

Expand Down Expand Up @@ -732,7 +732,7 @@ test_dates_parse <- function(directory = here::here(),
#log errors. Assume none until one is found.
error_log <- NULL

for(i in 1:length(seq_along(data_files))){
for(i in seq_along(data_files)){
data_file <- data_tbl[[i]][["physical"]][["objectName"]]

dttm_col_names <- dttm_attrs[[data_file]]$attributeName
Expand Down Expand Up @@ -771,6 +771,7 @@ test_dates_parse <- function(directory = here::here(),
col_types = do.call(readr::cols, dttm_col_spec),
show_col_types = FALSE))


#Arooo?
char_data <- suppressWarnings(
readr::read_csv(file.path(directory, data_file),
Expand All @@ -779,14 +780,31 @@ test_dates_parse <- function(directory = here::here(),
col_types = rep("c", length(dttm_col_names)),
show_col_types = FALSE))

for(j in 1:length(seq_along(dttm_col_names))){
for(j in seq_along(dttm_col_names)){

col_data <- dttm_data[[j]]
orig_na_count <- sum(is.na(char_data[[j]]))
if (all(is.na(col_data))) {
error_log <- append(error_log, paste0(" ", "---> {.file ", data_file, "} {.field ", dttm_col_names[j], "} (failed to parse)"))
#if entire column is NA:
if (all(is.na(col_data)) & all(is.na(char_data[[j]]))) {
error_log <- append(error_log,
paste0(" ",
"---> {.file ",
data_file,
"} {.field ",
dttm_col_names[j],
"} contains no data. Remove this column or use defined missing value codes to indicate data are missing." ))
} else if (all(is.na(col_data))) {
#if entire column failed to parse:
error_log <- append(error_log,
paste0(" ", "---> {.file ", data_file,
"} {.field ", dttm_col_names[j],
"} (failed to parse)"))
#if part of the column failed to parse:
} else if (sum(is.na(col_data)) > orig_na_count) {
error_log <- append(error_log, paste0(" ---> {.file ", data_file, "} {.field ", dttm_col_names[j], "} (partially failed to parse)"))
error_log <- append(error_log,
paste0(" ---> {.file ", data_file, "} {.field ",
dttm_col_names[j],
"} (partially failed to parse)"))
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<!-- badges: start -->
[![R-CMD-check](https://github.com/nationalparkservice/DPchecker/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nationalparkservice/DPchecker/actions/workflows/R-CMD-check.yaml)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CodeFactor](https://www.codefactor.io/repository/github/roblbaker/dpchecker/badge)](https://www.codefactor.io/repository/github/roblbaker/dpchecker)
<!-- badges: end -->

<!-- CMD-check badge...for once it's working...[![R-CMD-check](https://github.com/nationalparkservice/DPchecker/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nationalparkservice/DPchecker/actions/workflows/R-CMD-check.yaml) -->


# DPchecker

#### v0.3.2
#### v0.3.3

DPchecker (Data Package checker) is a package with a series of functions for NPS data package authors and reviewers to check for internal consistency among data/meta data and with the data package standards.

Expand Down
8 changes: 4 additions & 4 deletions docs/404.html

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

6 changes: 3 additions & 3 deletions docs/LICENSE-text.html

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

Loading

0 comments on commit ccec214

Please sign in to comment.