Skip to content

Commit

Permalink
deprecate 'warning' file_modification_check option, replace with fail…
Browse files Browse the repository at this point in the history
…ure. Correct out class documentation
  • Loading branch information
annakrystalli committed Sep 6, 2024
1 parent 7ed8a71 commit 07b0642
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 10 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: hubValidations
Title: Testing framework for hubverse hub validations
Version: 0.6.0
Version: 0.6.1
Authors@R: c(
person(
given = "Anna",
Expand Down Expand Up @@ -42,6 +42,7 @@ Imports:
hubUtils (>= 0.1.2),
jsonlite,
jsonvalidate,
lifecycle,
lubridate,
magrittr,
purrr,
Expand Down
2 changes: 1 addition & 1 deletion R/check_valid_round_id_col.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @return
#' Depending on whether validation has succeeded, one of:
#' - `<message/check_success>` condition class object.
#' - `<warning/check_warning>` condition class object.
#' - `<error/check_failure>` 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
14 changes: 11 additions & 3 deletions R/validate_pr.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' or deletion of a previously submitted model metadata file is detected in PR:
#' - `"error"`: Appends a `<error/check_error>` condition class object for each
#' applicable modified/deleted file.
#' - `"warning"`: Appends a `<warning/check_warning>` condition class object for each
#' - `"warning"`: Appends a `<error/check_failure>` condition class object for each
#' applicable modified/deleted file.
#' - `"message"`: Appends a `<message/check_info>` condition class object for each
#' applicable modified/deleted file.
Expand Down Expand Up @@ -100,7 +100,7 @@ validate_pr <- function(hub_path = ".", gh_repo, pr_number,
), validations_cfg_path = NULL,
skip_submit_window_check = FALSE,
file_modification_check = c(
"error", "warn",
"error", "failure", "warn",
"message", "none"
),
allow_submit_window_mods = TRUE,
Expand All @@ -110,6 +110,14 @@ validate_pr <- function(hub_path = ".", gh_repo, pr_number,
),
derived_task_ids = NULL) {
file_modification_check <- rlang::arg_match(file_modification_check)
if (file_modification_check == "warn") {
lifecycle::deprecate_warn(
"0.6.1",
"validate_pr(file_modification_check = 'will not accept option `warn` in
future versions. Use `failure` instead')"
)
file_modification_check <- "failure"
}
output_type_id_datatype <- rlang::arg_match(output_type_id_datatype)
model_output_dir <- get_hub_model_output_dir(hub_path) # nolint: object_name_linter
model_metadata_dir <- "model-metadata" # nolint: object_name_linter
Expand Down Expand Up @@ -251,7 +259,7 @@ check_pr_modf_del_files <- function(pr_df, file_type = c(
"model_output", # nolint
"model_metadata"
),
alert = c("message", "warn", "error"),
alert = c("message", "failure", "error"),
allow_submit_window_mods = TRUE) {
file_type <- rlang::arg_match(file_type)
alert <- rlang::arg_match(alert)
Expand Down
2 changes: 1 addition & 1 deletion man/check_valid_round_id_col.Rd

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

4 changes: 2 additions & 2 deletions man/validate_pr.Rd

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

15 changes: 14 additions & 1 deletion tests/testthat/test-validate_pr.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,26 @@ test_that("validate_pr flags modifications and deletions in PR", {
suppressMessages(check_for_errors(mod_checks_error))
)

# capture file_modification_check deprecation warning
expect_warning(
suppressMessages(
validate_pr(
hub_path = temp_hub,
gh_repo = "hubverse-org/ci-testhub-simple",
pr_number = 6,
skip_submit_window_check = TRUE,
file_modification_check = "warn"
)
)
)

mod_checks_warn <- suppressMessages(
validate_pr(
hub_path = temp_hub,
gh_repo = "hubverse-org/ci-testhub-simple",
pr_number = 6,
skip_submit_window_check = TRUE,
file_modification_check = "warn"
file_modification_check = "failure"
)
)
expect_snapshot(str(mod_checks_warn))
Expand Down
2 changes: 1 addition & 1 deletion vignettes/articles/validate-pr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ These settings can be modified if required though the use of arguments `file_mod
- **`file_modification_check`** controls whether modification/deletion checks are performed, what is returned if modifications/deletions are detected and accepts one of the following values:

- **`"error"`**: Appends a `<error/check_error>` condition class object for each applicable modified/deleted file. Will result in validation workflow failure.
- **`"warning"`**: Appends a `<warning/check_warning>` condition class object for each applicable modified/deleted file. Will result in validation workflow failure.
- **`"failure"`**: Appends a `<error/check_failure>` condition class object for each applicable modified/deleted file. Will result in validation workflow failure.
- **`"message"`**: Appends a `<message/check_info>` condition class object for each applicable modified/deleted file. Will not result in validation workflow failure.
- **`"none"`**: No modification/deletion checks performed.

Expand Down

0 comments on commit 07b0642

Please sign in to comment.