-
-
Notifications
You must be signed in to change notification settings - Fork 880
Description
While looking at some Quarto question about caching
I found out that setting cache.path = "./cache/ is not enough to remove the file dependency for the cache.
Here is an example of the content that digest(content) will be run on
content <-
list(eval = TRUE, echo = TRUE, results = "markup", tidy = FALSE,
tidy.opts = NULL, collapse = FALSE, prompt = FALSE, comment = NA,
highlight = TRUE, size = "normalsize", background = "#F7F7F7",
strip.white = TRUE, cache = 3, cache.path = "./cache/", cache.vars = NULL,
cache.lazy = TRUE, dependson = NULL, autodep = FALSE, fig.keep = "high",
fig.show = "asis", fig.align = "default", fig.path = "index_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = NULL,
fig.width = 7L, fig.height = 5L, fig.env = "figure", fig.cap = NULL,
fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL, fig.pos = "",
out.width = 672L, out.height = NULL, out.extra = NULL, fig.retina = 2,
external = TRUE, sanitize = FALSE, interval = 1, aniopts = "controls,loop",
warning = TRUE, error = FALSE, message = TRUE, render = NULL,
ref.label = NULL, child = NULL, engine = "R", split = FALSE,
purl = TRUE, fig.asp = NULL, fenced.echo = FALSE, ft.shadow = FALSE,
label = "unnamed-chunk-1", original.params.src = "r", chunk.echo = FALSE,
yaml.code = c("#| cache: true", "#| cache-path: \"./cache/\""
), code = c("Sys.sleep(10)", "cat(\"Hello, world!\")"), 75L)See fig.path = "index_files/figure-html/ - this will vary with input file. So two input files using the same label and the same code content won't be able to reuse the cache.
It seems in the past cache was more generic:
I wonder if this would be as easy as removing fig.path key 🤔
However, this matters for plots and file dependency, so maybe this is not easy—at least for cells with plots.
Current way to use generic cache today seems to be explicit caching through xfun::cache_exec() and specifying id with global cache (https://bookdown.org/yihui/rmarkdown-cookbook/cache-rds.html).
Use case
With Quarto running each document in its own session, it seems interesting to have a mechanism to be able to reuse code cells betwen document in a project.
Like ref.label but from another doc, with caching used. Maybe not realistic, but always good to have ideas! :)