Skip to content

Conversation

@dgkf
Copy link
Collaborator

@dgkf dgkf commented Jan 6, 2026

I spent some time before the holidays familiarizing myself with val.report and made a few changes to val.meter that I think will help streamline the reporting process.

I had a few goals in mind:

  1. Restructure the report package parameter to be more agnostic. Ideally, we should be able to pass in a pre-calculated pkg object (by Rds path), a DCF-formatted string of metrics (for example, from our repository), or a package name to be calculated on the fly.
  2. Support rich metadata in a tightly-integrated scenario. I'm imagining a case where we have a rich pkg object with full metadata and execution logs.
  3. Support good metadata in the loosely-integrated scenario -- for example when metrics are pulled from the repository PACKAGES file. We don't expect this to have full execution logs, but it should have metric data.

Will annotate the changes inline in comments.

@jthompson-arcus - let me know what you think of the logs capture. I know this was a contentious feature in riskmetric and would be curious to hear your thoughts on this approach.
@llrs-roche - would love to get your thoughts on some of the reporting-oriented changes.

@codecov-commenter
Copy link

codecov-commenter commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 57.84314% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.44%. Comparing base (2e001e7) to head (cd1bd91).

Files with missing lines Patch % Lines
R/class_pkg.R 55.00% 18 Missing ⚠️
R/class_resource.R 0.00% 6 Missing ⚠️
R/data_r_cmd_check.R 0.00% 5 Missing ⚠️
R/data_vignettes.R 0.00% 4 Missing ⚠️
R/utils_evaluate.R 73.33% 4 Missing ⚠️
R/data_web_html.R 0.00% 3 Missing ⚠️
R/data_desc.R 0.00% 2 Missing ⚠️
R/data_coverage.R 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #33      +/-   ##
==========================================
+ Coverage   20.58%   25.44%   +4.86%     
==========================================
  Files          33       34       +1     
  Lines        1404     1462      +58     
==========================================
+ Hits          289      372      +83     
+ Misses       1115     1090      -25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +78 to +87
method(convert, list(class_character, class_pkg)) <-
function(from, to, ...) {
if (endsWith(tolower(from), ".rds")) {
convert(readRDS(from), class_pkg)
} else if (grepl("\\bPackage:", from[[1L]])) {
pkg_from_dcf(from, ...)
} else {
pkg(from, ...)
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few extra handlers for converting a character string into a pkg object. Specifically ensuring that we can handle Rds file paths and DCF strings.

With these, whatever is passed to the report's package parameter, we can just run convert() on it to build a pkg() object and handle Rds paths, DCF strings and package names through a single interface.

Comment on lines +417 to +418
method(convert, list(class_list, class_pkg)) <-
function(from, to, ...) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly added handling for lists, which were effectively already handled inside the from_dcf method. Now it's just split into building a list from the DCF contents and then converting the list into a pkg object.

Comment on lines -34 to +36
nodes |>
xml2::xml_attr("href") |>
basename() |>
tools::file_path_sans_ext() |>
unique() |>
length()
paths <- xml2::xml_attr(nodes, "href")
filenames <- basename(paths)
filestems <- tools::file_path_sans_ext(filenames)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit of an unrelated fix, but noticed that the use of |> would force us to bump our minimum R version support so I just converted them into more traditional calls.

Comment on lines +59 to +64
capture <- evaluate::evaluate(
evaluate_fn,
stop_on_error = 1L,
debug = !isTRUE(quiet),
output_handler = evaluate::new_output_handler(value = identity)
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When logging is enabled we use evaluate to capture it.

It's off by default, since it's been a bit problematic in riskmetric; though here we're offloading all the nastiness of sinking output to a more mature package. Hopefully this is a bit more stable than what we had before, but still would prefer to keep it off by default until we have had an opportunity to stress test it a bit more.

Comment on lines +3 to +32
format.evaluate_evaluation <- function(
x,
...,
style = c("text", "ansi", "html")
) {
style <- match.arg(style)

if (
identical(style, "html") && !requireNamespace("htmltools", quietly = TRUE)
) {
stop(
"html formatting of evaluation logs requires suggested package ",
"`htmltools`"
)
}

out <- utils::capture.output(evaluate::replay(x))
switch(
style,
text = paste(cli::ansi_strip(out), collapse = "\n"),
ansi = paste(out, collapse = "\n"),
html = {
html <- cli::ansi_html(paste(out, collapse = "\n"))
htmltools::tags$div(
style = cli::ansi_html_style(colors = 8L),
htmltools::tags$pre(htmltools::HTML(html))
)
}
)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support prettier output of logs in the report, allow a style option that will hopefully make it easier to emit plain text or rich html reports.

Copy link
Contributor

@jthompson-arcus jthompson-arcus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgkf focused on the logging as requested. I don't think any of this structure would pose an issue to the accompanying Shiny app.

I did have a couple comments below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants