
Last chance! 50% off unlimited learning
Sale ends in
Cleans up the work done by make()
.
clean(..., list = character(0), destroy = FALSE, path = NULL,
search = NULL, cache = drake::drake_cache(path = path, verbose =
verbose), verbose = 1L, jobs = 1, force = FALSE,
garbage_collection = FALSE, purge = FALSE)
Targets to remove from the cache: as names (symbols) or
character strings. If the tidyselect
package is installed,
you can also supply dplyr
-style tidyselect
commands such as starts_with()
, ends_with()
, and one_of()
.
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.
Path to a drake
cache
(usually a hidden .drake/
folder) or NULL
.
Deprecated.
drake cache. See new_cache()
.
If supplied, path
is ignored.
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.
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
.
If you run clean()
with no arguments, drake
's response is to
remove all the targets etc. from the cache. To prevent you from
doing this accidentally in an interactive session, clean()
prompts you with a menu to confirm. The menu only appears
once per session. You can disable it with
options(drake_clean_menu = FALSE)
.
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.
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 {
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 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)
# 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.
build_times()
# To make even more room, use the "purge" flag.
clean(purge = TRUE)
build_times()
# Completely remove the entire cache (default: '.drake/' folder).
clean(destroy = TRUE)
}
})
# }
Run the code above in your browser using DataLab