drake (version 7.3.0)

get_cache: Get the default cache of a drake project.

Description

Only works if the cache is in a folder called .drake/. See the description of the path argument for details.

Usage

get_cache(path = getwd(), search = TRUE, verbose = 1L,
  force = FALSE, fetch_cache = NULL, console_log_file = NULL)

Arguments

path

Character, either the root file path of a drake project or a folder containing the root (top-level working directory where you plan to call make()). If this is too confusing, feel free to just use storr::storr_rds() to get the cache. If search = FALSE, path must be the root. If search = TRUE, you can specify any subdirectory of the project. Let's say "/home/you/my_project" is the root. The following are equivalent and correct:

  • get_cache(path = "/home/you/my_project", search = FALSE)

  • get_cache(path = "/home/you/my_project", search = TRUE)

  • get_cache(path = "/home/you/my_project/subdir/x", search = TRUE)

  • get_cache(path = "/home/you/my_project/.drake", search = TRUE)

  • get_cache(path = "/home/you/my_project/.drake/keys", search = TRUE)

search

Logical. If TRUE, search parent directories to find the nearest drake cache. Otherwise, look in the current working directory only. Ignored if a cache is supplied.

verbose

Integer, control printing to the console/terminal.

  • 0: print nothing.

  • 1: print targets, retries, and failures.

  • 2: also show a spinner when preprocessing tasks are underway.

force

Deprecated.

fetch_cache

Deprecated.

console_log_file

Optional character scalar of a file name or connection object (such as stdout()) to dump maximally verbose log information for make(). Independent of the verbose argument.

Value

A drake/storr cache in a folder called .drake/, if available. NULL otherwise.

See Also

new_cache(), drake_config()

Examples

Run this code
# NOT RUN {
isolate_example("Quarantine side effects.", {
if (suppressWarnings(require("knitr"))) {
clean(destroy = TRUE)
# No cache is available.
get_cache() # NULL
load_mtcars_example() # Get the code with drake_example("mtcars").
make(my_plan) # Run the project, build the targets.
x <- get_cache() # Now, there is a cache.
y <- storr::storr_rds(".drake") # Equivalent.
# List the objects readable from the cache with readd().
x$list()
}
})
# }

Run the code above in your browser using DataLab