make()
saves the values of your targets so
you rarely need to think about output files. By default,
the cache is a hidden folder called .drake/
.
You can also supply your own storr
cache to the cache
argument of make()
. The drake_cache()
function retrieves
this cache.
drake_cache(path = NULL, verbose = NULL, console_log_file = NULL)
path | Character.
Set |
---|---|
verbose | Deprecated on 2019-09-11. |
console_log_file | Deprecated on 2019-09-11. |
A drake/storr cache in a folder called .drake/
,
if available. NULL
otherwise.
drake_cache()
actually returns a decorated storr
,
an object that contains a storr
(plus bells and whistles).
To get the actual inner storr
, use drake_cache()$storr
.
Most methods are delegated to the inner storr
.
Some methods and objects are new or overwritten. Here
are the ones relevant to users.
history
: drake
's history (which powers drake_history()
)
is a txtq
. Access it
with drake_cache()$history
.
import()
: The import()
method is a function that can import
targets, function dependencies, etc. from one decorated storr
to another. History is not imported. For that, you have to work
with the history txtq
s themselves, Arguments to import()
:
...
and list
: specify targets to import just like with loadd()
.
Leave these blank to import everything.
from
: the decorated storr
from which to import targets.
jobs
: number of local processes for parallel computing.
gc
: TRUE
or FALSE
, whether to run garbage collection for memory
after importing each target. Recommended, but slow.
export()
: Same as import()
, except the from
argument is replaced
by to
: the decorated storr
where the targets end up.
if (FALSE) { isolate_example("Quarantine side effects.", { if (suppressWarnings(require("knitr"))) { clean(destroy = TRUE) # No cache is available. drake_cache() # NULL load_mtcars_example() # Get the code with drake_example("mtcars"). make(my_plan) # Run the project, build the targets. x <- drake_cache() # Now, there is a cache. y <- storr::storr_rds(".drake") # Nearly equivalent. # List the objects readable from the cache with readd(). x$list() # drake_cache() actually returns a *decorated* storr. # The *real* storr is inside. drake_cache()$storr } # You can import and export targets to and from decorated storrs. plan1 <- drake_plan(w = "w", x = "x") plan2 <- drake_plan(a = "a", x = "x2") cache1 <- new_cache("cache1") cache2 <- new_cache("cache2") make(plan1, cache = cache1) make(plan2, cache = cache2) cache1$import(cache2, a) cache1$get("a") cache1$get("x") cache1$import(cache2) cache1$get("x") # With txtq >= 0.1.6.9002, you can import history from one cache into # another. # nolint start # drake_history(cache = cache1) # cache1$history$import(cache2$history) # drake_history(cache = cache1) # nolint end }) }