R/clean.R
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 |
---|---|
list | character vector naming targets to be removed from the
cache. Similar to the |
destroy | logical, whether to totally remove the drake cache.
If |
path | Root directory of the drake project,
or if |
search | logical. If |
cache | drake cache. See |
verbose | logical or numeric, control printing to the console.
Use
|
jobs | Number of jobs for light parallelism (disabled on Windows). |
force | logical, whether to try to clean the cache even though the project may not be back compatible with the current version of drake. |
garbage_collection | logical, whether to call
|
purge | 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) }) # }