drake (version 6.2.1)

recover_cache: Load an existing drake files system cache if it exists or create a new one otherwise.

Description

Does not work with in-memory caches such as storr_environment().

Usage

recover_cache(path = drake::default_cache_path(),
  short_hash_algo = drake::default_short_hash_algo(),
  long_hash_algo = drake::default_long_hash_algo(), force = FALSE,
  verbose = drake::default_verbose(), fetch_cache = NULL,
  console_log_file = NULL)

Arguments

path

file path of the cache

short_hash_algo

short hash algorithm for the cache. See default_short_hash_algo() and make()

long_hash_algo

long hash algorithm for the cache. See default_long_hash_algo() and make()

force

logical, whether to load the cache despite any back compatibility issues with the running version of drake.

verbose

logical or numeric, control printing to the console. Use pkgconfig to set the default value of verbose for your R session: for example, pkgconfig::set_config("drake::verbose" = 2).

  • 0 or FALSE: print nothing.

  • 1 or TRUE: print only targets to build.

  • 2: also print checks and cache info.

  • 3: also print any potentially missing items.

  • 4: also print imports and writes to the cache.

fetch_cache

character vector containing lines of code. The purpose of this code is to fetch the storr cache with a command like storr_rds() or storr_dbi(), but customized. This feature is experimental. It will turn out to be necessary if you are using both custom non-RDS caches and distributed parallelism (parallelism = "future_lapply" or "Makefile") because the distributed R sessions need to know how to load the cache.

console_log_file

character scalar, connection object (such as stdout()) or NULL. If NULL, console output will be printed to the R console using message(). If a character scalar, console_log_file should be the name of a flat file, and console output will be appended to that file. If a connection object (e.g. stdout()) warnings and messages will be sent to the connection. For example, if console_log_file is stdout(), warnings and messages are printed to the console in real time (in addition to the usual in-bulk printing after each target finishes).

Value

A drake/storr cache.

See Also

new_cache(), this_cache(), get_cache()

Examples

Run this code
# NOT RUN {
test_with_dir("Quarantine side effects.", {
clean(destroy = TRUE)
load_mtcars_example() # Get the code with drake_example("mtcars").
make(my_plan) # Run the project, build all the targets.
x <- recover_cache(".drake") # Recover the project's storr cache.
})
# }

Run the code above in your browser using DataLab