From a4db9652f75a3430539f06f844385c044d01acc8 Mon Sep 17 00:00:00 2001 From: James Duncan Date: Tue, 10 Jan 2023 12:56:34 -0800 Subject: [PATCH 1/2] Don't run `render_docs()` in `R-CMD-check` workflow --- vignettes/simChef.Rmd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vignettes/simChef.Rmd b/vignettes/simChef.Rmd index ee0255b1..5c56a32c 100644 --- a/vignettes/simChef.Rmd +++ b/vignettes/simChef.Rmd @@ -31,6 +31,8 @@ for (fname in list.files(file.path("results", "Linear Regression Experiment"), pattern = ".rds", recursive = T, full.names = T)) { file.remove(fname) } + +eval_render_docs <- Sys.getenv("GITHUB_JOB") != "R-CMD-check" ``` # Overview @@ -322,11 +324,11 @@ The experiment can also be run in parallel. For a more detailed walkthrough on h Finally, we can easily visualize all results from the simulation experiment in an html file (generated using R Markdown) or browser. -```{r render_docs1, eval = FALSE} +```{r render_docs1, eval = eval_render_docs, warning = FALSE} render_docs(experiment, open = FALSE) ``` -```{r cp_html1, echo = FALSE, warning = FALSE, message = FALSE, results = "hide"} +```{r cp_html1, eval = eval_render_docs, echo = FALSE, warning = FALSE, message = FALSE, results = "hide"} # create pkgdown/assets directory, which will be copied to the gh-pages branch # during the pkgdown workflow (see .github/workflows/pkgdown.yaml) assets_dir <- here::here("pkgdown/assets") @@ -485,11 +487,11 @@ vary_cor_results <- experiment %>% ``` Now when generating the R Markdown report summary for an `Experiment`, the R Markdown will compile results (both evaluation and visualization results) from all saved `Experiments` under the root results directory `experiment$get_save_dir()`. Since the results from the many `vary_across` runs above are all saved under the original `experiment`'s results directory, then the following will include all of the above results in a single document. -```{r render_docs2, warning = FALSE} +```{r render_docs2, eval = eval_render_docs, warning = FALSE} render_docs(experiment, open = FALSE) ``` -```{r cp_html2, echo = FALSE, warning = FALSE, message = FALSE, results = "hide"} +```{r cp_html2, eval = eval_render_docs, echo = FALSE, warning = FALSE, message = FALSE, results = "hide"} # copy html output to pkgdown/assets directory for website file.copy(from = file.path(experiment$get_save_dir(), paste0(experiment$name, ".html")), From bd06f79c2873ea43c6cc4e394d5fec90a52e2835 Mon Sep 17 00:00:00 2001 From: James Duncan Date: Tue, 10 Jan 2023 14:06:56 -0800 Subject: [PATCH 2/2] Remove `results` dir at end of `simChef.Rmd` --- vignettes/simChef.Rmd | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/vignettes/simChef.Rmd b/vignettes/simChef.Rmd index 0436e798..51cd0b36 100644 --- a/vignettes/simChef.Rmd +++ b/vignettes/simChef.Rmd @@ -8,7 +8,9 @@ vignette: > %\VignetteEncoding{UTF-8} --- -```{r include = FALSE} +```{r setup, include = FALSE} +not_macos <- Sys.getenv("RUNNER_OS") != "macOS" + knitr::opts_chunk$set( collapse = TRUE, comment = "#>", @@ -16,20 +18,17 @@ knitr::opts_chunk$set( # see https://github.com/tidyverse/ggplot2/issues/2252#issuecomment-1006713187 # and https://github.com/lcolladotor/biocthis/issues/27 and # https://github.com/bodkan/slendr/commit/f0f5ae18452cc9df5d151874e41b0b8fd5f29aa2# - eval = Sys.getenv("RUNNER_OS") != "macOS" + eval = not_macos ) library(simChef) set.seed(12345) -# remove old cached results to start fresh -for (fname in list.files(file.path("results", "Linear Regression Experiment"), - pattern = ".rds", recursive = T, full.names = T)) { - file.remove(fname) -} +# remove any old results to start fresh +unlink("results", recursive = TRUE) -eval_render_docs <- Sys.getenv("GITHUB_JOB") != "R-CMD-check" +eval_render_docs <- not_macos && Sys.getenv("GITHUB_JOB") != "R-CMD-check" ``` # Overview @@ -752,7 +751,7 @@ All results from `experiment$run(..., save = TRUE)` without a `vary_across` comp Here's the directory tree of the "Linear Regression Experiment" example: -```{r, eval = FALSE} +```{r eval = FALSE} fs::dir_tree(get_save_dir(experiment)) #> results #> ├── Linear Gaussian DGP @@ -892,3 +891,7 @@ err_fun <- results$errors$.dgp[[1]]$dgp_fun # reproduce error via a direct call to the DGP function that raised the error err_fun() ``` + +```{r teardown, include = FALSE} +unlink("results", recursive = TRUE) +```