R/make.R
This is the central, most important function of the drake package. It runs all the steps of your workflow in the correct order, skipping any work that is already up to date. See https://github.com/ropensci/drake/blob/master/README.md#documentation for an overview of the documentation.
make(plan = read_drake_plan(), targets = drake::possible_targets(plan), envir = parent.frame(), verbose = drake::default_verbose(), hook = default_hook, cache = drake::get_cache(verbose = verbose, force = force), fetch_cache = NULL, parallelism = drake::default_parallelism(), jobs = 1, packages = rev(.packages()), prework = character(0), prepend = character(0), command = drake::default_Makefile_command(), args = drake::default_Makefile_args(jobs = jobs, verbose = verbose), recipe_command = drake::default_recipe_command(), log_progress = TRUE, imports_only = FALSE, timeout = Inf, cpu = NULL, elapsed = NULL, retries = 0, force = FALSE, return_config = NULL, graph = NULL, trigger = drake::default_trigger(), skip_imports = FALSE, skip_safety_checks = FALSE, config = NULL, lazy_load = "eager", session_info = TRUE, cache_log_file = NULL, seed = NULL, caching = "worker", keep_going = FALSE)
plan | workflow plan data frame.
A workflow plan data frame is a data frame
with a |
---|---|
targets | character vector, names of targets to build.
Dependencies are built too. Together, the |
envir | environment to use. Defaults to the current
workspace, so you should not need to worry about this
most of the time. A deep copy of |
verbose | logical or numeric, control printing to the console.
Use
|
hook | function with at least one argument.
The hook is as a wrapper around the code that drake uses
to build a target (see the body of |
cache | drake cache as created by |
fetch_cache | character vector containing lines of code.
The purpose of this code is to fetch the |
parallelism | character, type of parallelism to use.
To list the options, call |
jobs | number of parallel processes or jobs to run.
See Imports and targets are processed separately, and they usually
have different parallelism needs. To use at most 2 jobs at a time
for imports and at most 4 jobs at a time for targets, call
For If |
packages | character vector packages to load, in the order
they should be loaded. Defaults to |
prework | character vector of lines of code to run
before build time. This code can be used to
load packages, set options, etc., although the packages in the
|
prepend | lines to prepend to the Makefile if |
command | character scalar, command to call the Makefile
generated for distributed computing.
Only applies when |
args | command line arguments to call the Makefile for
distributed computing. For advanced users only. If set,
|
recipe_command | Character scalar, command for the Makefile recipe for each target. |
log_progress | logical, whether to log the progress
of individual targets as they are being built. Progress logging
creates a lot of little files in the cache, and it may make builds
a tiny bit slower. So you may see gains in storage efficiency
and speed with
|
imports_only | logical, whether to skip building the targets
in |
timeout | Seconds of overall time to allow before imposing
a timeout on a target. Passed to |
cpu | Seconds of cpu time to allow before imposing
a timeout on a target. Passed to |
elapsed | Seconds of elapsed time to allow before imposing
a timeout on a target. Passed to |
retries | Number of retries to execute if the target fails.
Assign target-level retries with an optional |
force | Force |
return_config | Logical, whether to return the internal list
of runtime configuration parameters used by |
graph | An |
trigger | Name of the trigger to apply to all targets.
Ignored if |
skip_imports | logical, whether to totally neglect to
process the imports and jump straight to the targets. This can be useful
if your imports are massive and you just want to test your project,
but it is bad practice for reproducible data analysis.
This argument is overridden if you supply your own |
skip_safety_checks | logical, whether to skip the safety checks on your workflow. Use at your own peril. |
config | Master configuration list produced by both
|
lazy_load | either a character vector or a logical. Choices:
If |
session_info | logical, whether to save the |
cache_log_file | Name of the cache log file to write.
If |
seed | integer, the root pseudo-random seed to use for your project.
To ensure reproducibility across different R sessions,
On the first call to |
caching | character string, only applies to |
keep_going | logical, whether to still keep running |
The master internal configuration list, mostly
containing arguments to make()
and important objects
constructed along the way. See config()
for more details.
drake_plan()
,
vis_drake_graph()
,
parallelism_choices()
,
max_useful_jobs()
,
triggers()
,
make_with_config()
# NOT RUN { test_with_dir("Quarantine side effects.", { load_basic_example() # Get the code with drake_example("basic"). config <- drake_config(my_plan) outdated(config) # Which targets need to be (re)built? my_jobs = max_useful_jobs(config) # Depends on what is up to date. make(my_plan, jobs = 2) # Build what needs to be built. outdated(config) # Everything is up to date. # Change one of your imported function dependencies. reg2 = function(d){ d$x3 = d$x^3 lm(y ~ x3, data = d) } outdated(config) # Some targets depend on reg2(). vis_drake_graph(config) # See how they fit in an interactive graph. make(my_plan) # Rebuild just the outdated targets. outdated(config) # Everything is up to date again. make(my_plan, cache_log_file = TRUE) # Write a text log file this time. vis_drake_graph(config) # The colors changed in the graph. clean() # Start from scratch. # Run with at most 2 jobs at a time for the imports # and at most 4 jobs at a time for the targets. make(my_plan, jobs = c(imports = 2, targets = 4)) clean() # Start from scratch. # Rerun with "Makefile" parallelism with at most 4 jobs. # Requires Rtools on Windows. # make(my_plan, parallelism = "Makefile", jobs = 4) # nolint clean() # Start from scratch. # Specify your own Makefile recipe. # Requires Rtools on Windows. # make(my_plan, parallelism = "Makefile", jobs = 4, # nolint # recipe_command = "R -q -e") # nolint # # make() respects tidy evaluation as implemented in the rlang package. # This workflow plan uses rlang's quasiquotation operator `!!`. my_plan <- drake_plan(list = c( little_b = "\"b\"", letter = "!!little_b" )) my_plan make(my_plan) readd(letter) # "b" }) # }