hubverse-org / hubValidations

Testing framework for hubverse hub validations
https://hubverse-org.github.io/hubValidations/
Other
1 stars 4 forks source link

Find way to print `missing` df when `check_tbl_values_required()` fails #16

Open annakrystalli opened 1 year ago

annakrystalli commented 1 year ago

Currently I'm just attaching a tibble of missing required rows that should be present given.

It would be nice to be able to print this to the console in a pretty way.

Briefly experimented with the following:

library(hubValidations)
hub_path <- system.file("testhubs/flusight", package = "hubUtils")
file_path <- "hub-ensemble/2023-05-08-hub-ensemble.parquet"
round_id <- "2023-05-08"
tbl <- read_model_out_file(file_path, hub_path)
res <- check_tbl_values_required(tbl[-(24:25), ], round_id, file_path, hub_path)
res
#> <warning/check_failure>
#> Warning:
#> Required task ID/output type/output type ID combinations missing.  See
#> `missing` attribute for details.

# Print tbl with cli - NOPE
c(names(res$missing), as.vector(t(res$missing))) %>%
    cli::ansi_columns(
        fill = "rows",
        max_cols = ncol(res$missing)) %>%
    cli::boxx()
#> ┌──────────────────────────────────────────────────────────────────────────────────────┐
#> │                                                                                      │
#> │   forecast_date              target                    horizon                       │
#> │   location                   output_type               output_type_id                │
#> │   2023-05-08                 wk ahead inc flu hosp     2                             │
#> │   US                         quantile                  0.01                          │
#> │   2023-05-08                 wk ahead inc flu hosp     2                             │
#> │   US                         quantile                  0.025                         │
#> │                                                                                      │
#> └──────────────────────────────────────────────────────────────────────────────────────┘

# Print tbl with huxtable
huxtable::as_hux(res$missing) %>%
    huxtable::print_screen()
#>      forecast_d   target       horizon   location   output_typ   output_typ  
#>             ate                                     e            e_id        
#>      2023-05-08   wk ahead           2   US         quantile     0.01        
#>                   inc flu                                                    
#>                   hosp                                                       
#>      2023-05-08   wk ahead           2   US         quantile     0.025       
#>                   inc flu                                                    
#>                   hosp                                                       
#> 
#> Column names: forecast_date, target, horizon, location, output_type,
#> output_type_id

Created on 2023-08-02 with reprex v2.0.2