drake (version 6.2.1)

drake_cache_log_file: Generate a flat text log file to represent the state of the cache.

Description

This functionality is like make(..., cache_log_file = TRUE), but separated and more customizable. The drake_cache_log_file() function writes a flat text file to represents the state of all the targets and imports in the cache. If you call it after each make() and put the log file under version control, you can track the changes to your results over time. This way, your data is versioned alongside your code in a easy-to-view format. Hopefully, this functionality is a step toward better data versioning tools.

Usage

drake_cache_log_file(file = "drake_cache.log", path = getwd(),
  search = TRUE, cache = drake::get_cache(path = path, search = search,
  verbose = verbose), verbose = drake::default_verbose(), jobs = 1,
  targets_only = FALSE)

Arguments

file

character scalar, name of the flat text log file.

path

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.

search

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.

cache

drake cache. See new_cache(). If supplied, path and search are ignored.

verbose

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).

  • 0 or FALSE: print nothing.

  • 1 or TRUE: print only targets to build.

  • 2: also print checks and cache info.

  • 3: also print any potentially missing items.

  • 4: also print imports and writes to the cache.

jobs

number of jobs/workers for parallel processing

targets_only

logical, whether to output information only on the targets in your workflow plan data frame. If targets_only is FALSE, the output will include the hashes of both targets and imports.

Value

There is no return value, but a log file is generated.

See Also

drake_cache_log(), make(), get_cache(), default_long_hash_algo(), short_hash(), long_hash()

Examples

Run this code
# NOT RUN {
test_with_dir("Quarantine side effects.", {
# Load drake's canonical example.
load_mtcars_example() # Get the code with drake_example()
# Run the project and save a flat text log file.
make(my_plan)
drake_cache_log_file() # writes drake_cache.log
# The above 2 lines are equivalent to make(my_plan, cache_log_file = TRUE) # nolint
# At this point, put drake_cache.log under version control
# (e.g. with 'git add drake_cache.log') alongside your code.
# Now, every time you run your project, your commit history
# of hash_lot.txt is a changelog of the project's results.
# It shows which targets and imports changed on every commit.
# It is extremely difficult to track your results this way
# by putting the raw '.drake/' cache itself under version control.
})
# }

Run the code above in your browser using DataLab