-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pulling first function from validator-1
ref #2
- Loading branch information
Showing
5 changed files
with
104 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
^trawler\.Rproj$ | ||
^\.Rproj\.user$ | ||
^LICENSE\.md$ | ||
^README\.Rmd$ | ||
^cran-comments\.md$ | ||
^\.github$ | ||
|
||
^codecov\.yml$ | ||
^cran-comments\.md$ | ||
^LICENSE\.md$ | ||
^README\.Rmd$ | ||
^trawler\.Rproj$ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
default: | ||
project_id: 1612 # This is located in data-public/metadata/validation-rules.yml also | ||
|
||
path_derived_pt_event_csv: "data-public/derived/pt-event.csv" | ||
path_derived_pt_event_rds: "data-public/derived/pt-event.rds" | ||
|
||
path_derived_smell_summary_csv: "data-public/derived/summary-smell.csv" | ||
path_derived_smell_summary_rds: "data-public/derived/summary-smell.rds" | ||
path_derived_rule_summary_csv: "data-public/derived/summary-rule.csv" | ||
path_derived_rule_summary_rds: "data-public/derived/summary-rule.rds" | ||
path_derived_rule_violation_csv: "data-public/derived/violation-rule.csv" | ||
path_derived_rule_violation_rds: "data-public/derived/violation-rule.rds" | ||
|
||
path_log_flow: !expr strftime(Sys.time(), "data-unshared/log/%Y/%Y-%m/flow-%Y-%m-%d--%H-%M-%S.log") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(load_checks) | ||
importFrom(rlang,.data) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#' @title Load and parse checks in a yaml file, and return a list | ||
#' of useful objects. | ||
#' @param path_checks The file path to the yaml file specifying the smells | ||
#' and rules. | ||
#' @export | ||
load_checks <- function (path_checks) { | ||
checkmate::assert_file_exists(path_checks, extension = c("yml", "yaml")) | ||
|
||
checks <- config::get(file = path_checks) | ||
|
||
smells <- load_smells(checks) | ||
|
||
list( | ||
ds_smell = smells$ds_smell, | ||
ds_smell_inactive = smells$ds_smell_inactive | ||
) | ||
} | ||
|
||
#' @importFrom rlang .data | ||
load_smells <- function (checks) { | ||
|
||
ds_smell <- | ||
checks$smells |> | ||
purrr::map_df(tibble::as_tibble) |> | ||
dplyr::filter(.data$smell_active) |> | ||
dplyr::mutate( | ||
debug = dplyr::coalesce(debug, FALSE), | ||
) | ||
|
||
ds_smell_inactive <- | ||
checks$smells |> | ||
purrr::map_df(tibble::as_tibble) |> | ||
dplyr::filter(!.data$smell_active) | ||
|
||
testit::assert("The count of distinct rule columns (in the yaml checks file) should be 10.", ncol(ds_smell) == 10L) | ||
testit::assert( # dput(colnames(ds_smell)) | ||
"The smell columns (in the yaml checks file) should be correct.", | ||
colnames(ds_smell) == c("check_name", "description", "priority", "smell_active", "debug", "bound_lower", "bound_upper", "bounds_template", "value_template", "equation") | ||
) | ||
|
||
ds_smell <- | ||
ds_smell |> | ||
dplyr::mutate( | ||
boundaries = sprintf(.data$bounds_template, .data$bound_lower, .data$bound_upper), | ||
) | ||
# table(ds_smell$check_name) | ||
# OuhscMunge::verify_value_headstart(ds_smell) | ||
checkmate::assert_character(ds_smell$check_name , any.missing=F , pattern="^.{4,99}$" , unique=T) | ||
checkmate::assert_character(ds_smell$description , any.missing=F , pattern="^.{4,255}$" , unique=T) | ||
checkmate::assert_integer( ds_smell$priority , any.missing=F , lower=1, upper=5 ) | ||
checkmate::assert_logical( ds_smell$smell_active , any.missing=F ) | ||
checkmate::assert_logical( ds_smell$debug , any.missing=F ) | ||
checkmate::assert_numeric( ds_smell$bound_lower , any.missing=F ) | ||
checkmate::assert_numeric( ds_smell$bound_upper , any.missing=F ) | ||
checkmate::assert_character(ds_smell$bounds_template , any.missing=F , pattern="^.{2,255}$" ) | ||
checkmate::assert_character(ds_smell$value_template , any.missing=F , pattern="^.{2,255}$" ) | ||
checkmate::assert_character(ds_smell$equation , any.missing=F , pattern="^.{5,}$" , unique=T) | ||
checkmate::assert_character(ds_smell$boundaries , any.missing=F , pattern="^.{6,}$" ) | ||
|
||
list( | ||
ds_smell = ds_smell, | ||
ds_smell_inactive = ds_smell_inactive | ||
) | ||
} | ||
|
||
# load_checks("data-public/metadata/validation-rules.yml") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.