diff --git a/NAMESPACE b/NAMESPACE index b5a60b3c..4e2af418 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,6 +7,7 @@ S3method(tp,data.frame) export(DGP) export(Evaluator) export(Experiment) +export(HTML) export(Method) export(Visualizer) export(add_dgp) diff --git a/R/docs.R b/R/docs.R index 18b8a587..92794983 100644 --- a/R/docs.R +++ b/R/docs.R @@ -167,6 +167,17 @@ create_doc_template <- function(experiment, save_dir) { #' @param viz_order Vector of `Visualizer` names in their desired order for #' display. By default, the report will display the `Visualizer` results #' in the order that they were computed. +#' @param eval_cache File extension of the cached evaluator results to read in. +#' Typically `".rds"` or `"none"`, but can be any file extension where +#' evaluator results are stored as `eval_results.ext` and can be read in +#' using `data.table::fread(eval_results.ext)`. If `"none"`, evaluator results +#' are computed using the experiment via [evaluate_experiment()]. +#' @param viz_cache File extension of the cached visualizer results to read in. +#' Typically `".rds"` or `"none"`, but can be any (image) file extension +#' (e.g., `"png"`, `"jpg"`) where the visualizer results have been previously +#' stored as separate `{visualizer_name}.ext` images (typically using +#' [export_visualizers()]). If `"none"`, visualizer results are computed using +#' the experiment via [visualize_experiment()]. #' @param use_icons Logical indicating whether or not to use fontawesome icons. #' @param verbose Level of verboseness (0, 1, 2) when knitting R Markdown. #' Default is 2. @@ -189,7 +200,9 @@ render_docs <- function(experiment, save_dir, write_rmd = FALSE, output_file = NULL, output_format = vthemes::vmodern(), title = NULL, author = "", show_code = TRUE, show_eval = TRUE, show_viz = TRUE, - eval_order = NULL, viz_order = NULL, use_icons = TRUE, + eval_order = NULL, viz_order = NULL, + eval_cache = ".rds", viz_cache = ".rds", + use_icons = TRUE, quiet = TRUE, verbose = 2, ...) { if (missing(experiment) && missing(save_dir)) { @@ -269,7 +282,9 @@ render_docs <- function(experiment, save_dir, write_rmd = FALSE, sim_name = title, sim_path = save_dir, author = author, write_filename = sprintf("%s.Rmd", output_file), show_code = show_code, show_eval = show_eval, show_viz = show_viz, - eval_order = eval_order, viz_order = viz_order, use_icons = use_icons, + eval_order = eval_order, viz_order = viz_order, + eval_cache = eval_cache, viz_cache = viz_cache, + use_icons = use_icons, use_vmodern = use_vmodern, write = write_rmd, verbose = verbose ) diff --git a/R/experiment.R b/R/experiment.R index c4fe5b63..b0734cd9 100644 --- a/R/experiment.R +++ b/R/experiment.R @@ -2005,7 +2005,7 @@ Experiment <- R6::R6Class( #' @param ... Additional arguments to pass to [ggplot2::ggsave()]. #' #' @return The `Experiment` object, invisibly. - export_visualizers = function(device = "pdf", width = "auto", height = "auto", + export_visualizers = function(device = "png", width = "auto", height = "auto", ...) { rlang::check_installed("ggplot2", reason = "to export visualizers to image.") @@ -2020,7 +2020,6 @@ Experiment <- R6::R6Class( } else { save_dir <- private$.get_vary_across_dir() } - save_dir <- file.path(save_dir, "viz_results") if (!dir.exists(save_dir)) { dir.create(save_dir, recursive = TRUE) } diff --git a/R/utils.R b/R/utils.R index 84ffeac4..ca4c95f8 100644 --- a/R/utils.R +++ b/R/utils.R @@ -513,7 +513,7 @@ check_results_names <- function(names, method_name) { #' `after`, and `outside` (equivalent to `before` and `end`). #' #' @returns The input `text`, but marked as HTML. -#' @keywords internal +#' @export HTML <- function(text, ..., .noWS = NULL) { htmlText <- c(text, as.character(rlang::dots_list(...))) diff --git a/_pkgdown.yml b/_pkgdown.yml index 9155cf8c..3b95587a 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -40,6 +40,7 @@ reference: - init_docs - render_docs - create_rmd + - HTML - title: "DGP" desc: > Functions for creating a DGP (data-generating process). diff --git a/inst/rmd/results.Rmd b/inst/rmd/results.Rmd index a8b01ba8..1fb6febb 100644 --- a/inst/rmd/results.Rmd +++ b/inst/rmd/results.Rmd @@ -31,6 +31,12 @@ params: viz_order: label: "Order of Visualizers:" value: NULL + eval_cache: + label: "Evaluators Cache Type:" + value: ".rds" + viz_cache: + label: "Visualizers Cache Type:" + value: ".rds" use_icons: label: "Use Icons:" value: TRUE @@ -338,18 +344,119 @@ show_recipe <- function(field_name = c( } #' Reads in file if it exists and returns NULL if the file does not exist +#' +#' @description If filetype is ".rds", the file is read in using readRDS(). +#' Otherwise, the file is read in using data.table::fread(). #' -#' @param filename name of .rds file to try reading in -#' @return output of filename.rds if the file exists and NULL otherwise -get_results <- function(filename) { +#' @param filename name of file (with file extension) to try reading in +#' @return output of filename if the file exists and NULL otherwise +get_results <- function(filename, filetype = ".rds") { if (file.exists(filename)) { - results <- readRDS(filename) + if (filetype == ".rds") { + results <- readRDS(filename) + } else { + results <- data.table::fread(results) + } } else { results <- NULL } return(results) } +#' Reads in list of image result files +#' +#' @param filenames vector of filenames (without file extension) to read in +#' @param filetype file extension +#' @return list of image results, wrapped as knitr::include_graphics() objects +get_image_results <- function(filenames, filetype) { + purrr::map( + filenames, + function(f) { + if (file.exists(sprintf("%s%s", f, filetype))) { + return(knitr::include_graphics(sprintf("%s%s", f, filetype))) + } else { + return(NULL) + } + } + ) |> + setNames(basename(filenames)) |> + purrr::compact() +} + +#' Get results from experiment +#' +#' @param dir_name name of directory +#' @param show_eval logical; whether or not to show evaluators +#' @param show_viz logical; whether or not to show visualizers +#' @param eval_cache file extension for cached evaluator results to read in. +#' Typically ".rds" or "none", but can be any file extension where +#' evaluator results are stored as `eval_results.ext` and can be read in +#' using `data.table::fread(eval_results.ext)`. If "none", evaluator results +#' are computed using the experiment via `evaluate_experiment()`. +#' @param viz_cache file extension for cached visualizer results to read in. +#' Typically ".rds" or "none", but can be any (image) file extension +#' (e.g., "png", "jpg") where the visualizer results have been previously +#' stored as separate `{visualizer_name}.ext` images (e.g., using +#' `export_visualizers()`). If "none", visualizer results are computed using +#' the experiment via `visualize_experiment()`. +get_exp_results <- function(dir_name, + show_eval = TRUE, show_viz = TRUE, + eval_cache = ".rds", viz_cache = ".rds") { + + exp_fname <- file.path(dir_name, "experiment.rds") + fit_fname <- file.path(dir_name, "fit_results.rds") + eval_fname <- file.path(dir_name, sprintf("eval_results%s", eval_cache)) + viz_fname <- file.path(dir_name, sprintf("viz_results%s", viz_cache)) + + exp <- get_results(exp_fname) + fit_results <- NULL + eval_results <- NULL + viz_results <- NULL + if ((eval_cache != "none") && (viz_cache == ".rds")) { + if (show_eval) { + eval_results <- get_results(eval_fname, eval_cache) + } + if (show_viz) { + viz_results <- get_results(viz_fname, viz_cache) + } + } else { + if (show_eval) { + if (eval_cache == "none") { + fit_results <- get_results(fit_fname) + eval_results <- evaluate_experiment(exp, fit_results) + } else { + eval_results <- get_results(eval_fname, eval_cache) + } + } + if (show_viz) { + if (viz_cache == ".rds") { + viz_results <- get_results(viz_fname, viz_cache) + } else if (viz_cache == "none") { + if (is.null(fit_results)) { + fit_results <- get_results(fit_fname) + } + if (is.null(eval_results)) { + eval_results <- get_results(eval_fname) + if (is.null(eval_results)) { + eval_results <- evaluate_experiment(exp, fit_results) + } + } + viz_results <- visualize_experiment(exp, fit_results, eval_results) + } else { + viz_results <- get_image_results( + file.path(dir_name, names(exp$get_visualizers())), viz_cache + ) + } + } + } + results <- list( + exp = exp, + eval_results = eval_results, + viz_results = viz_results + ) + return(results) +} + #' Displays output (both from evaluate() and visualize()) from saved results under #' a specified directory #' @@ -428,14 +535,26 @@ show_results <- function(dir_name, depth, base = FALSE, show_header = TRUE, code_label <- "Varying Parameters" } - exp_fname <- file.path(dir_name, "experiment.rds") - eval_fname <- file.path(dir_name, "eval_results.rds") - viz_fname <- file.path(dir_name, "viz_results.rds") - - exp <- get_results(exp_fname) - eval_results <- get_results(eval_fname) - viz_results <- get_results(viz_fname) + exp_results <- get_exp_results( + dir_name, + show_eval = params$show_eval, show_viz = params$show_viz, + eval_cache = params$eval_cache, viz_cache = params$viz_cache + ) + exp <- exp_results$exp + eval_results <- exp_results$eval_results + viz_results <- exp_results$viz_results + if (write_flag && (params$show_eval || params$show_viz)) { + results <- sprintf( + "results <- get_exp_results(\n '%s', show_eval = %s, show_viz = %s, eval_cache = '%s', viz_cache = '%s'\n)", + dir_name, + params$show_eval, params$show_viz, + params$eval_cache, params$viz_cache + ) |> + write_code_chunk(chunk_args = "results = 'asis'") |> + write(old_text = results, write_flag = write_flag) + } + if (!is.null(eval_results) && params$show_eval) { results <- write( sprintf(showtype_template, evaluator_label), @@ -471,7 +590,7 @@ show_results <- function(dir_name, depth, base = FALSE, show_header = TRUE, } if (write_flag) { results <- sprintf( - "show_results('%s', '%s', 'evaluator')", dir_name, eval_name + "show_results(results, '%s', 'evaluator')", eval_name ) |> write_code_chunk(chunk_args = "results = 'asis'") |> write(old_text = results, write_flag = write_flag) @@ -522,7 +641,8 @@ show_results <- function(dir_name, depth, base = FALSE, show_header = TRUE, plt <- plts[[plt_name]] is_plot <- inherits(plt, "plotly") || inherits(plt, "gg") || - inherits(plt, "ggplot") + inherits(plt, "ggplot") || + inherits(plt, "knit_image_paths") if (params$use_vmodern && is_plot) { chunk_args <- "fig.height = %s, fig.width = %s, out.width = '100%%', add.panel = TRUE" @@ -534,7 +654,7 @@ show_results <- function(dir_name, depth, base = FALSE, show_header = TRUE, if (write_flag) { results <- sprintf( - "show_results('%s', '%s', 'visualizer')", dir_name, viz_name + "show_results(results, '%s', 'visualizer')", viz_name ) |> write_code_chunk( chunk_args = sprintf( @@ -567,9 +687,7 @@ show_results <- function(dir_name, depth, base = FALSE, show_header = TRUE, old_text = results, write_flag = write_flag ) if (write_flag) { - results <- sprintf( - "show_results('%s', NULL, 'vary_params')", dir_name - ) |> + results <- c("show_results(results, NULL, 'vary_params')") |> write_code_chunk(chunk_args = "max.height='200px'") |> write(old_text = results, write_flag = write_flag) } else { diff --git a/inst/rmd/results_header_template.Rmd b/inst/rmd/results_header_template.Rmd index abbf97e5..42b8e096 100644 --- a/inst/rmd/results_header_template.Rmd +++ b/inst/rmd/results_header_template.Rmd @@ -21,6 +21,8 @@ options( knitr.kable.NA = 'NA' ) +library(simChef) + local({ hook_output <- knitr::knit_hooks$get("output") knitr::knit_hooks$set( @@ -69,19 +71,120 @@ get_descendants <- function(dir_name) { return(experiments) } -#' Reads in file if it exists and returns NULL if the file does not exist. +#' Reads in file if it exists and returns NULL if the file does not exist +#' +#' @description If filetype is ".rds", the file is read in using readRDS(). +#' Otherwise, the file is read in using data.table::fread(). #' -#' @param filename Name of .rds file to try reading in. -#' @return Output of filename.rds if the file exists and NULL otherwise. -get_results <- function(filename) { +#' @param filename name of file (with file extension) to try reading in +#' @return output of filename if the file exists and NULL otherwise +get_results <- function(filename, filetype = ".rds") { if (file.exists(filename)) { - results <- readRDS(filename) + if (filetype == ".rds") { + results <- readRDS(filename) + } else { + results <- data.table::fread(results) + } } else { results <- NULL } return(results) } +#' Reads in list of image result files +#' +#' @param filenames vector of filenames (without file extension) to read in +#' @param filetype file extension +#' @return list of image results, wrapped as knitr::include_graphics() objects +get_image_results <- function(filenames, filetype) { + purrr::map( + filenames, + function(f) { + if (file.exists(sprintf("%s%s", f, filetype))) { + return(knitr::include_graphics(sprintf("%s%s", f, filetype))) + } else { + return(NULL) + } + } + ) |> + setNames(basename(filenames)) |> + purrr::compact() +} + +#' Get results from experiment +#' +#' @param dir_name name of directory +#' @param show_eval logical; whether or not to show evaluators +#' @param show_viz logical; whether or not to show visualizers +#' @param eval_cache file extension for cached evaluator results to read in. +#' Typically ".rds" or "none", but can be any file extension where +#' evaluator results are stored as `eval_results.ext` and can be read in +#' using `data.table::fread(eval_results.ext)`. If "none", evaluator results +#' are computed using the experiment via `evaluate_experiment()`. +#' @param viz_cache file extension for cached visualizer results to read in. +#' Typically ".rds" or "none", but can be any (image) file extension +#' (e.g., "png", "jpg") where the visualizer results have been previously +#' stored as separate `{visualizer_name}.ext` images (e.g., using +#' `export_visualizers()`). If "none", visualizer results are computed using +#' the experiment via `visualize_experiment()`. +get_exp_results <- function(dir_name, + show_eval = TRUE, show_viz = TRUE, + eval_cache = ".rds", viz_cache = ".rds") { + + exp_fname <- file.path(dir_name, "experiment.rds") + fit_fname <- file.path(dir_name, "fit_results.rds") + eval_fname <- file.path(dir_name, sprintf("eval_results%s", eval_cache)) + viz_fname <- file.path(dir_name, sprintf("viz_results%s", viz_cache)) + + exp <- get_results(exp_fname) + fit_results <- NULL + eval_results <- NULL + viz_results <- NULL + if ((eval_cache != "none") && (viz_cache == ".rds")) { + if (show_eval) { + eval_results <- get_results(eval_fname, eval_cache) + } + if (show_viz) { + viz_results <- get_results(viz_fname, viz_cache) + } + } else { + if (show_eval) { + if (eval_cache == "none") { + fit_results <- get_results(fit_fname) + eval_results <- evaluate_experiment(exp, fit_results) + } else { + eval_results <- get_results(eval_fname, eval_cache) + } + } + if (show_viz) { + if (viz_cache == ".rds") { + viz_results <- get_results(viz_fname, viz_cache) + } else if (viz_cache == "none") { + if (is.null(fit_results)) { + fit_results <- get_results(fit_fname) + } + if (is.null(eval_results)) { + eval_results <- get_results(eval_fname) + if (is.null(eval_results)) { + eval_results <- evaluate_experiment(exp, fit_results) + } + } + viz_results <- visualize_experiment(exp, fit_results, eval_results) + } else { + viz_results <- get_image_results( + file.path(dir_name, names(exp$get_visualizers())), viz_cache + ) + } + } + } + results <- list( + exp = exp, + eval_results = eval_results, + viz_results = viz_results + ) + return(results) +} + #' Show recipe content. #' #' @param objs List of DGP/Method/Evaluator/Visualizer objects. Should be one of @@ -114,16 +217,12 @@ show_recipe <- function(objs, name, experiment_name, #' @param field_name One of "evaluator", "visualizer", or "vary_params", #' indicating whether to return the results of an Evaluator, Visualizer, or #' the varying across parameters of the Experiment, respectively. -show_results <- function(dir_name, name, +show_results <- function(results, name, field_name = c("evaluator", "visualizer", "vary_params")) { field_name <- match.arg(field_name) - exp_fname <- file.path(dir_name, "experiment.rds") - eval_fname <- file.path(dir_name, "eval_results.rds") - viz_fname <- file.path(dir_name, "viz_results.rds") - - exp <- get_results(exp_fname) - eval_results <- get_results(eval_fname) - viz_results <- get_results(viz_fname) + exp <- results$exp + eval_results <- results$eval_results + viz_results <- results$viz_results if (field_name == "evaluator") { doc_nrows <- exp$get_evaluators()[[name]]$doc_nrows diff --git a/man/Experiment.Rd b/man/Experiment.Rd index c6437d54..f396b4d8 100644 --- a/man/Experiment.Rd +++ b/man/Experiment.Rd @@ -1030,7 +1030,7 @@ Export all cached \code{Visualizer} results from an \code{Experiment}'s results directory (see \code{\link[=get_save_dir]{get_save_dir()}}). \subsection{Usage}{ \if{html}{\out{
}}\preformatted{Experiment$export_visualizers( - device = "pdf", + device = "png", width = "auto", height = "auto", ... diff --git a/man/HTML.Rd b/man/HTML.Rd index e2c9cf1d..ffdf3f11 100644 --- a/man/HTML.Rd +++ b/man/HTML.Rd @@ -23,4 +23,3 @@ The input \code{text}, but marked as HTML. Marks the given text as HTML, which means the tag functions will know not to perform HTML escaping on it. Copy of \code{htmltools::HTML()}. } -\keyword{internal} diff --git a/man/render_docs.Rd b/man/render_docs.Rd index 67dcf723..16081449 100644 --- a/man/render_docs.Rd +++ b/man/render_docs.Rd @@ -18,6 +18,8 @@ render_docs( show_viz = TRUE, eval_order = NULL, viz_order = NULL, + eval_cache = ".rds", + viz_cache = ".rds", use_icons = TRUE, quiet = TRUE, verbose = 2, @@ -75,6 +77,19 @@ in the order that they were computed.} display. By default, the report will display the \code{Visualizer} results in the order that they were computed.} +\item{eval_cache}{File extension of the cached evaluator results to read in. +Typically \code{".rds"} or \code{"none"}, but can be any file extension where +evaluator results are stored as \code{eval_results.ext} and can be read in +using \code{data.table::fread(eval_results.ext)}. If \code{"none"}, evaluator results +are computed using the experiment via \code{\link[=evaluate_experiment]{evaluate_experiment()}}.} + +\item{viz_cache}{File extension of the cached visualizer results to read in. +Typically \code{".rds"} or \code{"none"}, but can be any (image) file extension +(e.g., \code{"png"}, \code{"jpg"}) where the visualizer results have been previously +stored as separate \verb{\{visualizer_name\}.ext} images (typically using +\code{\link[=export_visualizers]{export_visualizers()}}). If \code{"none"}, visualizer results are computed using +the experiment via \code{\link[=visualize_experiment]{visualize_experiment()}}.} + \item{use_icons}{Logical indicating whether or not to use fontawesome icons.} \item{quiet}{An option to suppress printing during rendering from knitr, diff --git a/tests/testthat/test-docs.R b/tests/testthat/test-docs.R index e6b5fb82..64a7532b 100644 --- a/tests/testthat/test-docs.R +++ b/tests/testthat/test-docs.R @@ -29,6 +29,7 @@ withr::with_tempdir(pattern = "simChef-test-checkpointing-temp", code = { add_evaluator(evaluator, "Evaluator") |> add_visualizer(visualizer, "Plot") results <- base_experiment$run(save = TRUE, verbose = 0) + export_visualizers(base_experiment) child1 <- create_experiment( name = "child1", @@ -36,12 +37,14 @@ withr::with_tempdir(pattern = "simChef-test-checkpointing-temp", code = { save_dir = file.path(base_experiment$get_save_dir(), "child1") ) results <- child1$run(save = TRUE, verbose = 0) + export_visualizers(child1) child2 <- create_experiment( name = "child2", clone_from = base_experiment, save_dir = file.path(base_experiment$get_save_dir(), "child2") ) results <- child2$run(save = TRUE, verbose = 0) + export_visualizers(child2) grandchild1a <- create_experiment( name = "grandchild1a", @@ -49,6 +52,7 @@ withr::with_tempdir(pattern = "simChef-test-checkpointing-temp", code = { save_dir = file.path(child1$get_save_dir(), "grandchild1a") ) results <- grandchild1a$run(save = TRUE, verbose = 0) + export_visualizers(grandchild1a) grandchild1b <- create_experiment( name = "grandchild1b", @@ -56,6 +60,7 @@ withr::with_tempdir(pattern = "simChef-test-checkpointing-temp", code = { save_dir = file.path(child1$get_save_dir(), "grandchild1b") ) results <- grandchild1b$run(save = TRUE, verbose = 0) + export_visualizers(grandchild1b) grandchild2 <- create_experiment( name = "grandchild2", @@ -63,6 +68,7 @@ withr::with_tempdir(pattern = "simChef-test-checkpointing-temp", code = { save_dir = file.path(child2$get_save_dir(), "grandchild2") ) results <- grandchild2$run(save = TRUE, verbose = 0) + export_visualizers(grandchild2) greatgrandchild2 <- create_experiment( name = "greatgrandchild2", @@ -70,6 +76,7 @@ withr::with_tempdir(pattern = "simChef-test-checkpointing-temp", code = { save_dir = file.path(grandchild2$get_save_dir(), "greatgrandchild2") ) results <- greatgrandchild2$run(save = TRUE, verbose = 0) + export_visualizers(greatgrandchild2) expect_error(render_docs(base_experiment, verbose = 0), NA) expect_error( @@ -86,6 +93,36 @@ withr::with_tempdir(pattern = "simChef-test-checkpointing-temp", code = { NA ) + # check different cache modes for evaluators and visualizers + expect_error( + render_docs( + base_experiment, verbose = 0, + eval_cache = ".rds", viz_cache = "none" + ), + NA + ) + expect_error( + render_docs( + base_experiment, verbose = 0, + eval_cache = "none", viz_cache = ".rds" + ), + NA + ) + expect_error( + render_docs( + base_experiment, verbose = 0, + eval_cache = "none", viz_cache = "none" + ), + NA + ) + expect_error( + render_docs( + base_experiment, verbose = 0, + eval_cache = "none", viz_cache = ".png" + ), + NA + ) + # check ... arguments to rmarkdown::render() expect_error( render_docs( @@ -162,6 +199,30 @@ withr::with_tempdir(pattern = "simChef-test-checkpointing-temp", code = { # ), # NA # ) + expect_error( + render_docs( + base_experiment, write_rmd = TRUE, verbose = 0, + output_file = file.path(base_experiment$get_save_dir(), "test3"), + eval_cache = "none", viz_cache = "none" + ), + NA + ) + expect_error( + rmarkdown::render(file.path(base_experiment$get_save_dir(), "test3.Rmd")), + NA + ) + expect_error( + render_docs( + base_experiment, write_rmd = TRUE, verbose = 0, + output_file = file.path(base_experiment$get_save_dir(), "test4"), + eval_cache = "none", viz_cache = ".png" + ), + NA + ) + expect_error( + rmarkdown::render(file.path(base_experiment$get_save_dir(), "test4.Rmd")), + NA + ) # check defuse requirement output_format <- quote(rmarkdown::html_document()) diff --git a/tests/testthat/test-experiment.R b/tests/testthat/test-experiment.R index b1e36d2f..6b0c29ce 100644 --- a/tests/testthat/test-experiment.R +++ b/tests/testthat/test-experiment.R @@ -983,18 +983,20 @@ withr::with_tempdir(pattern = "simChef-test-checkpointing-temp", code = { add_method(method, "Method") fit_results <- experiment$fit(verbose = 0) eval_results <- experiment$evaluate(fit_results, verbose = 0) - fpath <- file.path(experiment$get_save_dir(), "viz_results") + fpath <- file.path(experiment$get_save_dir()) # with no visualizers expect_error(experiment$export_visualizers(), NA) - expect_equal(length(list.files(path = fpath)), 0) + expect_equal( + length(list.files(path = fpath, pattern = ".png")), 0 + ) # warning if can't export visualizer experiment |> add_visualizer(plotly_plot, name = "plotly") viz_results <- experiment$visualize(fit_results, eval_results, save = TRUE, verbose = 0) expect_warning(experiment |> export_visualizers()) - expect_equal(length(list.files(path = fpath)), 0) + expect_equal(length(list.files(path = fpath, pattern = ".png")), 0) # with one working visualizer experiment |> @@ -1003,7 +1005,7 @@ withr::with_tempdir(pattern = "simChef-test-checkpointing-temp", code = { viz_results <- experiment$visualize(fit_results, eval_results, save = TRUE, verbose = 0) expect_warning(expect_warning(experiment$export_visualizers())) - expect_equal(list.files(path = fpath), "ggplot.pdf") + expect_equal(list.files(path = fpath, pattern = ".png"), "ggplot.png") # using vary across experiment |> @@ -1012,9 +1014,10 @@ withr::with_tempdir(pattern = "simChef-test-checkpointing-temp", code = { expect_warning(expect_warning(experiment$export_visualizers())) expect_equal( list.files( - path = file.path(experiment$get_save_dir(), "DGP", "Varying y", "viz_results") + path = file.path(experiment$get_save_dir(), "DGP", "Varying y"), + pattern = ".png" ), - "ggplot.pdf" + "ggplot.png" ) })