hubverse-org / hubAdmin

Utilities for administering hubverse Infectious Disease Modeling Hubs
https://hubverse-org.github.io/hubAdmin/
Other
1 stars 2 forks source link

add class to output of `validate_` functions #35

Closed zkamvar closed 1 month ago

zkamvar commented 1 month ago

This provides a class to the output of the validate_ functions so that the user is given a bird's-eye view of the different problems encountered.

This also changes behavior for parsing errors: if a file is missing or malformed, the result is not an error, but an invalid result with the result of the error. The reason I chose this is because in the case of validate_hub_config(), if the model metadata config is missing (as it is in the simple hub example), then the validation fails and the error is a bit cryptic.

The output for validate_config() looks like this when there is a schema error (the error that takes 6 pages to print in the vignette):

library(hubAdmin)
config_path <- system.file("error-schema/tasks-errors.json",
                           package = "hubUtils")
validate_config(config_path = config_path, config = "tasks")
#> Warning: Schema errors detected in config file
#> '/home/zhian/R/x86_64-pc-linux-gnu-library/4.4/hubUtils/error-schema/tasks-errors.json'
#> validated against schema
#> <https://raw.githubusercontent.com/hubverse-org/schemas/main/v0.0.0.9/tasks-schema.json>
#> [1] FALSE
#> ! 7 schema errors: error-schema/tasks-errors.json
#>   (<file:///home/zhian/R/x86_64-pc-linux-gnu-library/4.4/hubUtils/error-schema/tasks-errors.json>)
#>   (via tasks-schema v0.0.0.9
#>   (<https://raw.githubusercontent.com/hubverse-org/schemas/main/v0.0.0.9/tasks-schema.json>))
#> ℹ use `view_config_val_errors()` to view the errors in a table.

Created on 2024-08-09 with reprex v2.1.1

In RStudio or positron these messages would be succinct, and you would get clickable links which means that you can immediately inspect the results.

pretty-print-errors

This will fix #32

github-actions[bot] commented 1 month ago

🚀 Deployed on https://66bfb44dac8fdba76780798b--hubadmin-pr-previews.netlify.app

zkamvar commented 1 month ago

Also, would you mind just double checking what effects (if any) these changes have on the hubValidations tests before merging?

I tested this and there is no adverse effect.