Learn R Programming

drake (version 5.2.1)

build_drake_graph: Create the igraph dependency network of your project.

Description

This function returns an igraph object representing how the targets in your workflow plan data frame depend on each other. (help(package = "igraph")). To plot the graph, call to plot.igraph() on your graph, or just use vis_drake_graph() from the start.

Usage

build_drake_graph(plan = read_drake_plan(),
  targets = drake::possible_targets(plan), envir = parent.frame(),
  verbose = drake::default_verbose(), jobs = 1, sanitize_plan = TRUE,
  console_log_file = NULL)

Arguments

plan

workflow plan data frame. A workflow plan data frame is a data frame with a target column and a command column. (See the details in the drake_plan() help file for descriptions of the optional columns.) Targets are the objects and files that drake generates, and commands are the pieces of R code that produce them. Use the function drake_plan() to generate workflow plan data frames easily, and see functions plan_analyses(), plan_summaries(), evaluate_plan(), expand_plan(), and gather_plan() for easy ways to generate large workflow plan data frames.

targets

character vector, names of targets to build. Dependencies are built too. Together, the plan and targets comprise the workflow network (i.e. the graph argument). Changing either will change the network.

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 envir is made, so you don't need to worry about your workspace being modified by make. The deep copy inherits from the global environment. Wherever necessary, objects and functions are imported from envir and the global environment and then reproducibly tracked as dependencies.

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:

in addition, print checks and cache info.

3:

in addition, print any potentially missing items.

4:

in addition, print imports. Full verbosity.

jobs

number of parallel processes or jobs to run. See max_useful_jobs() or vis_drake_graph() to help figure out what the number of jobs should be. Windows users should not set jobs > 1 if parallelism is "mclapply" because mclapply() is based on forking. Windows users who use parallelism = "Makefile" will need to download and install Rtools.

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 make(..., jobs = c(imports = 2, targets = 4)).

For "future_lapply" parallelism, jobs only applies to the imports. To set the max number of jobs for "future_lapply" parallelism, set the workers argument where it exists: for example, call future::plan(multisession(workers = 4)), then call make(your_plan, parallelism = "future_lapply"). You might also try options(mc.cores = jobs), or see future::.options for environment variables that set the max number of jobs.

If parallelism is "Makefile", Makefile-level parallelism is only used for targets in your workflow plan data frame, not imports. To process imported objects and files, drake selects the best parallel backend for your system and uses the number of jobs you give to the jobs argument to make(). To use at most 2 jobs for imports and at most 4 jobs for targets, run make(..., parallelism = "Makefile", jobs = c(imports = 2, targets = 4)) or make(..., parallelism = "Makefile", jobs = 2, args = "--jobs=4").

sanitize_plan

logical, whether to sanitize the workflow plan first.

console_log_file

character scalar or NULL. If NULL, console output will be printed to the R console using message(). Otherwise, console_log_file should be the name of a flat file. Console output will be appended to that file.

Value

An igraph object representing the workflow plan dependency network.

See Also

vis_drake_graph()

Examples

Run this code
# NOT RUN {
test_with_dir("Quarantine side effects.", {
load_mtcars_example() # Get the code with drake_example("mtcars").
# Make the igraph network connecting all the targets and imports.
g <- build_drake_graph(my_plan)
class(g) # "igraph"
})
# }

Run the code above in your browser using DataLab