drake (version 7.3.0)

rescue_cache: Try to repair a drake cache that is prone to throwing storr-related errors.

Description

Sometimes, storr caches may have dangling orphaned files that prevent you from loading or cleaning. This function tries to remove those files so you can use the cache normally again.

Usage

rescue_cache(targets = NULL, path = getwd(), search = TRUE,
  verbose = 1L, force = FALSE, cache = drake::get_cache(path = path,
  search = search, verbose = verbose, force = force), jobs = 1,
  garbage_collection = FALSE)

Arguments

targets

Character vector, names of the targets to rescue. As with many other drake utility functions, the word target is defined generally in this case, encompassing imports as well as true targets. If targets is NULL, everything in the cache is rescued.

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.

cache

A storr cache object.

jobs

Number of jobs for light parallelism (disabled on Windows).

garbage_collection

Logical, whether to do garbage collection as a final step. See drake_gc() and clean() for details.

Value

The rescued drake/storr cache.

See Also

get_cache(), cached(), drake_gc(), clean()

Examples

Run this code
# NOT RUN {
isolate_example("Quarantine side effects.", {
if (suppressWarnings(require("knitr"))) {
load_mtcars_example() # Get the code with drake_example("mtcars").
make(my_plan) # Run the project, build targets. This creates the cache.
# Remove dangling cache files that could cause errors.
rescue_cache(jobs = 2)
# Alternatively, just rescue targets 'small' and 'large'.
# Rescuing specific targets is usually faster.
rescue_cache(targets = c("small", "large"))
}
})
# }

Run the code above in your browser using DataCamp Workspace