Skip to content

Commit

Permalink
Add custom function capabilitie to validate_model_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
annakrystalli committed Sep 15, 2023
1 parent 58d2ad6 commit 93fd4de
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
12 changes: 9 additions & 3 deletions R/validate_model_metadata.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Valid properties of a metadata file.
#'
#' @inheritParams check_tbl_colnames
#' @inheritParams validate_model_file
#' @return An object of class `hub_validations`. Each named element contains
#' a `hub_check` class object reflecting the result of a given check. Function
#' will return early if a check returns an error.
Expand All @@ -15,10 +15,14 @@
#' validate_model_file(hub_path,
#' file_path = "team1-goodmodel.yml"
#' )
validate_model_metadata <- function(hub_path, file_path) {
validate_model_metadata <- function(hub_path, file_path,
validations_cfg_path = NULL) {
checks <- list()
class(checks) <- c("hub_validations", "list")

file_meta <- parse_file_name(file_path)
round_id <- file_meta$round_id

checks$metadata_schema_exists <- check_metadata_schema_exists(hub_path)
if (is_error(checks$metadata_schema_exists)) {
return(checks)
Expand Down Expand Up @@ -54,7 +58,9 @@ validate_model_metadata <- function(hub_path, file_path) {
return(checks)
}

# TODO: Add section for custom file checks
custom_checks <- execute_custom_checks(validations_cfg_path = validations_cfg_path)
checks <- c(checks, custom_checks)
class(checks) <- c("hub_validations", "list")

checks
}
5 changes: 4 additions & 1 deletion man/validate_model_metadata.Rd

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

29 changes: 15 additions & 14 deletions vignettes/articles/custom-functions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,22 @@ Within the default configuration, individual checks can be configured for each o
Note that each of the `validate_*()` functions contain a standard objects in their call environment which are passed automatically to any custom check function and therefore do not need including in the `args` configuration.

- **`validate_model_file`:**
- `file_path`
- `hub_path`
- `round_id`
- `file_meta`
- `file_path`: character string of path to file being validated relative to the `model-output` directory.
- `hub_path`: character string of path to hub.
- `round_id`: character string of `round_id`
- `file_meta`: named list containing `round_id`, `team_abbr`, `model_abbr` and `model_id` details.
- **`validate_model_data`:**
- `tbl`
- `file_path`
- `hub_path`
- `round_id`
- `file_meta`
- `round_id_col`
- **`validate_model_data`:**
- `file_path`
- `hub_path`
- `round_id`
- `tbl`: a tibble of the model output data being validated.
- `file_path`: character string of path to file being validated relative to the `model-output` directory.
- `hub_path`: character string of path to hub.
- `round_id`: character string of `round_id`
- `file_meta`: named list containing `round_id`, `team_abbr`, `model_abbr` and `model_id` details.
- `round_id_col`: character string of name of `tbl` column containing `round_id` information.
- **`validate_model_metadata`:**
- `file_path`: character string of path to file being validated relative to the `model-output` directory.
- `hub_path`: character string of path to hub.
- `round_id`: character string of `round_id`
- `file_meta`: named list containing `round_id`, `team_abbr`, `model_abbr` and `model_id` details.

The `args` configuration can be used to override objects from the caller environment.

Expand Down

0 comments on commit 93fd4de

Please sign in to comment.