Skip to content

Commit

Permalink
Change all check_failure class objects from warning to error sub-clas…
Browse files Browse the repository at this point in the history
…ses. Resolves #111
  • Loading branch information
annakrystalli committed Sep 2, 2024
1 parent 8c8b2f4 commit c5295f3
Show file tree
Hide file tree
Showing 47 changed files with 216 additions and 165 deletions.
6 changes: 3 additions & 3 deletions R/capture_check_cnd.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' the state when validation succeeds, the second element, when validation fails.
#' @param error logical. In the case of validation failure, whether the function
#' should return an object of class `<error/check_error>` (`TRUE`) or
#' `<warning/check_failure>` (`FALSE`, default).
#' `<error/check_failure>` (`FALSE`, default).
#' @param details further details to be appended to the output message.
#' @inheritParams rlang::error_cnd
#'
Expand All @@ -22,7 +22,7 @@
#' @return Depending on whether validation has succeeded and the value
#' of the `error` argument, one of:
#' - `<message/check_success>` condition class object.
#' - `<warning/check_failure>` condition class object.
#' - `<error/check_failure>` condition class object.
#' - `<error/check_error>` condition class object.
#'
#' Returned object also inherits from subclass `<hub_check>`.
Expand Down Expand Up @@ -82,7 +82,7 @@ capture_check_cnd <- function(check, file_path, msg_subject, msg_attribute,
use_cli_format = TRUE
)
} else {
res <- rlang::warning_cnd(
res <- rlang::error_cnd(
c("check_failure", "hub_check"),
where = file_path,
...,
Expand Down
2 changes: 1 addition & 1 deletion R/check_tbl_col_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @return
#' Depending on whether validation has succeeded, one of:
#' - `<message/check_success>` condition class object.
#' - `<warning/check_failure>` condition class object.
#' - `<error/check_failure>` condition class object.
#'
#' Returned object also inherits from subclass `<hub_check>`.
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/check_tbl_unique_round_id.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @return
#' Depending on whether validation has succeeded, one of:
#' - `<message/check_success>` condition class object.
#' - `<warning/check_error>` condition class object.
#' - `<error/check_error>` condition class object.
#'
#' If `round_id_from_variable: false` and no `round_id_col` name is provided,
#' check is skipped and a `<message/check_info>` condition class object is
Expand Down
4 changes: 2 additions & 2 deletions man/capture_check_cnd.Rd

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

2 changes: 1 addition & 1 deletion man/check_file_location.Rd

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

2 changes: 1 addition & 1 deletion man/check_metadata_file_ext.Rd

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

2 changes: 1 addition & 1 deletion man/check_metadata_file_location.Rd

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

2 changes: 1 addition & 1 deletion man/check_metadata_file_name.Rd

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

2 changes: 1 addition & 1 deletion man/check_metadata_matches_schema.Rd

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

2 changes: 1 addition & 1 deletion man/check_metadata_schema_exists.Rd

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

2 changes: 1 addition & 1 deletion man/check_submission_time.Rd

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

2 changes: 1 addition & 1 deletion man/check_tbl_col_types.Rd

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

2 changes: 1 addition & 1 deletion man/check_tbl_match_round_id.Rd

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

2 changes: 1 addition & 1 deletion man/check_tbl_rows_unique.Rd

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

2 changes: 1 addition & 1 deletion man/check_tbl_spl_n.Rd

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

2 changes: 1 addition & 1 deletion man/check_tbl_unique_round_id.Rd

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

2 changes: 1 addition & 1 deletion man/check_tbl_value_col.Rd

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

2 changes: 1 addition & 1 deletion man/check_tbl_value_col_ascending.Rd

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

2 changes: 1 addition & 1 deletion man/check_tbl_value_col_sum1.Rd

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

2 changes: 1 addition & 1 deletion man/check_tbl_values_required.Rd

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

2 changes: 1 addition & 1 deletion man/opt_check_metadata_team_max_model_n.Rd

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

2 changes: 1 addition & 1 deletion man/opt_check_tbl_col_timediff.Rd

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

2 changes: 1 addition & 1 deletion man/opt_check_tbl_counts_lt_popn.Rd

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

2 changes: 1 addition & 1 deletion man/opt_check_tbl_horizon_timediff.Rd

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

18 changes: 10 additions & 8 deletions tests/testthat/_snaps/capture_check_cnd.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
capture_check_cnd(check = FALSE, file_path = "test/file.csv", msg_subject = "{.var round_id}",
msg_attribute = "valid.", error = FALSE, details = "Must be one of {.val {c('A', 'B')}}, not {.val C}")
Output
<warning/check_failure>
Warning:
`round_id` must be valid. Must be one of "A" and "B", not "C"
<error/check_failure>
Error:
! `round_id` must be valid. Must be one of "A" and "B", not "C"

---

Expand Down Expand Up @@ -46,9 +46,9 @@
msg_attribute = "consistent with expected round task IDs and std column names.",
msg_verbs = c("are", "must always be"))
Output
<warning/check_failure>
Warning:
Column names must always be consistent with expected round task IDs and std column names.
<error/check_failure>
Error:
! Column names must always be consistent with expected round task IDs and std column names.

---

Expand All @@ -57,12 +57,14 @@
msg_attribute = "consistent with expected round task IDs and std column names.",
msg_verbs = c("are", "must always be")))
Output
List of 4
List of 6
$ message : chr "Column names must always be consistent with expected round task IDs and std column names. \n "
$ trace : NULL
$ parent : NULL
$ where : chr "test/file.csv"
$ call : chr "eval"
$ use_cli_format: logi TRUE
- attr(*, "class")= chr [1:5] "check_failure" "hub_check" "rlang_warning" "warning" ...
- attr(*, "class")= chr [1:5] "check_failure" "hub_check" "rlang_error" "error" ...

# capture_check_cnd fails correctly

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/check_file_location.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Code
check_file_location("team1-goodmodel/2022-10-08-team2-goodmodel.csv")
Output
<warning/check_failure>
Warning:
File directory name must match `model_id` metadata in file name. File should be submitted to directory "team2-goodmodel" not "team1-goodmodel"
<error/check_failure>
Error:
! File directory name must match `model_id` metadata in file name. File should be submitted to directory "team2-goodmodel" not "team1-goodmodel"

6 changes: 3 additions & 3 deletions tests/testthat/_snaps/check_metadata_file_location.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Code
check_metadata_file_location("random_folder/hub-baseline.yml")
Output
<warning/check_failure>
Warning:
Metadata file directory name must match "model-metadata". Metadata files should be submitted to directory "model-metadata", not "model-metadata/random_folder".
<error/check_failure>
Error:
! Metadata file directory name must match "model-metadata". Metadata files should be submitted to directory "model-metadata", not "model-metadata/random_folder".

6 changes: 3 additions & 3 deletions tests/testthat/_snaps/check_tbl_col_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
Code
check_tbl_col_types(tbl, file_path, hub_path)
Output
<warning/check_failure>
Warning:
Column data types do not match hub schema. `origin_date` should be "character" not "Date", `horizon` should be "double" not "integer".
<error/check_failure>
Error:
! Column data types do not match hub schema. `origin_date` should be "character" not "Date", `horizon` should be "double" not "integer".

# Check '06' location value validated correctly in check_tbl_col_types

Expand Down
12 changes: 7 additions & 5 deletions tests/testthat/_snaps/check_tbl_match_round_id.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,22 @@
check_tbl_match_round_id(tbl = tbl, file_path = file_path, hub_path = hub_path,
round_id_col = "random_column")
Output
<warning/check_error>
Warning:
`round_id_col` name must be valid. Must be one of "origin_date", "target", "horizon", and "location" not "random_column".
<error/check_error>
Error:
! `round_id_col` name must be valid. Must be one of "origin_date", "target", "horizon", and "location" not "random_column".

---

Code
str(check_tbl_match_round_id(tbl = tbl, file_path = file_path, hub_path = hub_path,
round_id_col = "random_column"))
Output
List of 4
List of 6
$ message : chr "`round_id_col` name must be valid. \n Must be one of\n \"origin_date\", \""| __truncated__
$ trace : NULL
$ parent : NULL
$ where : chr "hub-baseline/2022-10-01-hub-baseline.csv"
$ call : chr "check_tbl_match_round_id"
$ use_cli_format: logi TRUE
- attr(*, "class")= chr [1:5] "check_error" "hub_check" "rlang_warning" "warning" ...
- attr(*, "class")= chr [1:5] "check_error" "hub_check" "rlang_error" "error" ...

6 changes: 3 additions & 3 deletions tests/testthat/_snaps/check_tbl_rows_unique.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Code
check_tbl_rows_unique(rbind(tbl, tbl[c(5, 9), ]), file_path, hub_path)
Output
<warning/check_failure>
Warning:
All combinations of task ID column/`output_type`/`output_type_id` values must be unique. Rows containing duplicate combinations: 48 and 49
<error/check_failure>
Error:
! All combinations of task ID column/`output_type`/`output_type_id` values must be unique. Rows containing duplicate combinations: 48 and 49

Loading

0 comments on commit c5295f3

Please sign in to comment.