-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from hubverse-org/ak/detect-dup-model-outpus-…
…sans-ext/139
- Loading branch information
Showing
15 changed files
with
425 additions
and
17 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
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
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,40 @@ | ||
#' Check number of files submitted per round does not exceed the allowed number | ||
#' of submissions per team. | ||
#' | ||
#' @inheritParams check_tbl_col_types | ||
#' @param allowed_n integer(1). The maximum number of files allowed per round. | ||
#' @inherit check_tbl_col_types return | ||
#' | ||
#' @export | ||
check_file_n <- function(file_path, hub_path, allowed_n = 1L) { | ||
checkmate::assert_integer(allowed_n, lower = 1L, len = 1L) | ||
file_name <- basename(file_path) | ||
file_name_sans_ext <- fs::path_ext_remove(file_name) | ||
team_dir <- dirname(abs_file_path(file_path, hub_path)) | ||
|
||
existing_files <- fs::dir_ls(team_dir, regex = file_name_sans_ext) |> | ||
fs::path_rel(dirname(team_dir)) |> | ||
setdiff(file_path) # Remove file being validated from check | ||
existing_n <- length(existing_files) | ||
|
||
check <- existing_n < allowed_n | ||
|
||
if (check) { | ||
details <- NULL | ||
} else { | ||
details <- cli::format_inline( | ||
"Should be {.val {allowed_n}} but {cli::qty(existing_n)} pre-existing round | ||
submission file{?s} {.val {existing_files}} found in team directory." | ||
) | ||
} | ||
|
||
capture_check_cnd( | ||
check = check, | ||
file_path = file_path, | ||
msg_subject = "Number of accepted model output files per round", | ||
msg_verbs = c("met.", "exceeded."), | ||
msg_attribute = NULL, | ||
error = FALSE, | ||
details = details | ||
) | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,10 @@ | ||
# check_file_n works | ||
|
||
Code | ||
check_file_n(file_path = "team1-goodmodel/2022-10-08-team1-goodmodel.parquet", | ||
hub_path) | ||
Output | ||
<error/check_failure> | ||
Error: | ||
! Number of accepted model output files per round exceeded. Should be 1 but pre-existing round submission file "team1-goodmodel/2022-10-08-team1-goodmodel.csv" found in team directory. | ||
|
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
Oops, something went wrong.