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.
Arguments
- path
Character. Set
path
to the path of astorr::storr_rds()
cache to retrieve a specific cache generated bystorr::storr_rds()
ordrake::new_cache()
. If thepath
argument isNULL
,drake_cache()
searches up through parent directories to find a folder called.drake/
.- verbose
Deprecated on 2019-09-11.
- console_log_file
Deprecated on 2019-09-11.
Details
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 powersdrake_history()
) is atxtq
. Access it withdrake_cache()$history
.import()
: Theimport()
method is a function that can import targets, function dependencies, etc. from one decoratedstorr
to another. History is not imported. For that, you have to work with the historytxtq
s themselves, Arguments toimport()
:...
andlist
: specify targets to import just like withloadd()
. Leave these blank to import everything.from
: the decoratedstorr
from which to import targets.jobs
: number of local processes for parallel computing.gc
:TRUE
orFALSE
, whether to run garbage collection for memory after importing each target. Recommended, but slow.
export()
: Same asimport()
, except thefrom
argument is replaced byto
: the decoratedstorr
where the targets end up.
Examples
if (FALSE) { # \dontrun{
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
})
} # }