Cleans up the work done by make()
.
clean(..., list = character(0), destroy = FALSE, path = getwd(),
search = TRUE, cache = NULL, verbose = drake::default_verbose(),
jobs = 1, force = FALSE, garbage_collection = FALSE, purge = FALSE)
targets to remove from the cache: as names (symbols),
character strings, or dplyr
-style tidyselect
commands such as starts_with()
.
character vector naming targets to be removed from the
cache. Similar to the list
argument of remove()
.
logical, whether to totally remove the drake cache.
If destroy
is FALSE
, only the targets
from make()
are removed. If TRUE
, the whole cache is removed, including
session metadata, etc.
Root directory of the drake project,
or if search
is TRUE
, either the
project root or a subdirectory of the project.
Ignored if a cache
is supplied.
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.
drake cache. See new_cache()
.
If supplied, path
and search
are ignored.
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)
.
FALSE
:print nothing.
TRUE
:print only targets to build.
in addition, print checks and cache info.
in addition, print any potentially missing items.
in addition, print imports. Full verbosity.
Number of jobs for light parallelism (disabled on Windows).
logical, whether to try to clean the cache even though the project may not be back compatible with the current version of drake.
logical, whether to call
cache$gc()
to do garbage collection.
If TRUE
, cached data with no remaining references
will be removed.
This will slow down clean()
, but the cache
could take up far less space afterwards.
See the gc()
method for storr
caches.
logical, whether to remove objects from metadata namespaces such as "meta", "build_times", and "errors".
Invisibly return NULL
.
By default, clean()
removes references to cached data.
To deep-clean the data to free up storage/memory, use
clean(garbage_collection = TRUE)
. Garbage collection is slower,
but it purges data with no remaining references. To just do garbage
collection without cleaning, see drake_gc()
.
Also, for clean()
, you must be in your project's working directory
or a subdirectory of it.
clean(search = TRUE)
searches upwards in your folder structure
for the drake cache and acts on the first one it sees. Use
search = FALSE
to look within the current working
directory only.
WARNING: This deletes ALL work done with make()
,
which includes
file targets as well as the entire drake cache. Only use clean()
if you're sure you won't lose anything important.
# NOT RUN {
test_with_dir("Quarantine side effects.", {
load_basic_example() # Get the code with drake_example("basic").
make(my_plan) # Run the project, build the targets.
# List objects in the cache, excluding R objects
# imported from your workspace.
cached(no_imported_objects = TRUE)
# Remove 'summ_regression1_large' and 'small' from the cache.
clean(summ_regression1_large, small)
# Those objects should be gone.
cached(no_imported_objects = TRUE)
# How about `tidyselect`?
clean(starts_with("coef"))
cached(no_imported_objects = TRUE)
# Rebuild the missing targets.
make(my_plan)
# Remove all the targets and imports.
# On non-Windows machines, parallelize over at most 2 jobs.
clean(jobs = 2)
# Make the targets again.
make(my_plan)
# Garbage collection removes data whose references are no longer present.
# It is slow, but you should enable it if you want to reduce the
# size of the cache.
clean(garbage_collection = TRUE)
# All the targets and imports are gone.
cached()
# But there is still cached metadata.
names(read_drake_meta())
build_times()
# To make even more room, use the "purge" flag.
clean(purge = TRUE)
names(read_drake_meta())
build_times()
# Completely remove the entire cache (default: '.drake/' folder).
clean(destroy = TRUE)
})
# }
Run the code above in your browser using DataLab