From 55b50e4064731c280755c21a52dad63389e0891e Mon Sep 17 00:00:00 2001 From: wlandau Date: Sun, 21 Jul 2019 10:39:27 -0400 Subject: [PATCH] Eliminate accidental creations of .drake_history/ --- DESCRIPTION | 2 +- NEWS.md | 7 + R/api-codetoplan.R | 1 + R/api-exposeimports.R | 2 + R/api-progress.R | 2 + R/api-read.R | 4 + R/api-slice.R | 2 + R/api-usedrake.R | 2 + R/drake_plan_helpers.R | 1 - R/drake_plan_keywords.R | 6 + R/exec-imports.R | 2 - R/exec-memory.R | 2 - R/utils-deprecate.R | 362 ------------------------------ R/utils-encoding.R | 62 ++--- R/utils-graphinfo.R | 2 +- R/vis-console.R | 4 + man/Makefile_recipe.Rd | 3 - man/available_hash_algos.Rd | 3 - man/bind_plans.Rd | 1 - man/build_drake_graph.Rd | 3 - man/clean_main_example.Rd | 9 - man/configure_cache.Rd | 3 - man/default_Makefile_args.Rd | 3 - man/default_Makefile_command.Rd | 3 - man/default_long_hash_algo.Rd | 3 - man/default_parallelism.Rd | 3 - man/default_recipe_command.Rd | 3 - man/default_short_hash_algo.Rd | 3 - man/deps_targets.Rd | 10 - man/drake_batchtools_tmpl_file.Rd | 3 - man/drake_cache_log_file.Rd | 3 - man/drake_envir.Rd | 4 + man/drake_quotes.Rd | 3 - man/drake_session.Rd | 3 - man/drake_slice.Rd | 2 + man/drake_strings.Rd | 3 - man/drake_unquote.Rd | 3 - man/evaluate_plan.Rd | 85 ------- man/expand_plan.Rd | 17 -- man/expose_imports.Rd | 2 + man/failed.Rd | 2 + man/file_store.Rd | 42 ++-- man/gather_by.Rd | 30 --- man/gather_plan.Rd | 32 --- man/get_cache.Rd | 17 -- man/knitr_in.Rd | 2 + man/legend_nodes.Rd | 2 +- man/load_main_example.Rd | 9 - man/long_hash.Rd | 3 - man/make_imports.Rd | 3 - man/make_targets.Rd | 3 - man/make_with_config.Rd | 3 - man/manage_memory.Rd | 3 - man/map_plan.Rd | 32 --- man/parallelism_choices.Rd | 3 - man/plan_analyses.Rd | 3 - man/plan_summaries.Rd | 3 - man/process_import.Rd | 3 - man/prune_drake_graph.Rd | 3 - man/r_recipe_wildcard.Rd | 3 - man/read_drake_config.Rd | 3 - man/read_drake_graph.Rd | 3 - man/read_drake_plan.Rd | 3 - man/read_drake_seed.Rd | 4 + man/reduce_by.Rd | 32 --- man/reduce_plan.Rd | 32 --- man/render_static_drake_graph.Rd | 3 - man/shell_file.Rd | 3 - man/short_hash.Rd | 3 - man/show_source.Rd | 4 + man/static_drake_graph.Rd | 3 - man/triggers.Rd | 3 - man/use_drake.Rd | 2 + 73 files changed, 107 insertions(+), 833 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0f2b96eba..fa60ec242 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,7 +11,7 @@ Description: A general-purpose computational engine for data analysis, to practical examples and more, is available at the reference website and the online manual . -Version: 7.5.1 +Version: 7.5.2 License: GPL-3 URL: https://github.com/ropensci/drake BugReports: https://github.com/ropensci/drake/issues diff --git a/NEWS.md b/NEWS.md index e1a1a7f7d..7ca107b41 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# Version 7.5.2 + +## Bug fixes + +- Eliminate accidental creations of `.drake_history` in `plan_to_code()`, `plan_to_notebook()`, and the examples in the help files. + + # Version 7.5.1 ## Bug fixes diff --git a/R/api-codetoplan.R b/R/api-codetoplan.R index 3ab1dda94..05e0382e1 100644 --- a/R/api-codetoplan.R +++ b/R/api-codetoplan.R @@ -146,6 +146,7 @@ plan_to_text <- function(plan) { plan[, c("target", "command")], envir = new.env(parent = emptyenv()), cache = storr::storr_environment(), + history = FALSE, verbose = FALSE )$graph order <- igraph::topo_sort(graph)$name diff --git a/R/api-exposeimports.R b/R/api-exposeimports.R index 48374c2ad..dbe36271b 100644 --- a/R/api-exposeimports.R +++ b/R/api-exposeimports.R @@ -32,6 +32,7 @@ #' of the imports. #' @examples #' \dontrun{ +#' isolate_example("contain side effects", { #' # Suppose you have a workflow that uses the `digest()` function, #' # which computes the hash of an object. #' @@ -84,6 +85,7 @@ #' } #' config <- drake_config(plan, cache = cache, history = FALSE) #' tracked(config) +#' }) #' } expose_imports <- function( package, diff --git a/R/api-progress.R b/R/api-progress.R index 5d182caed..b6742b73a 100644 --- a/R/api-progress.R +++ b/R/api-progress.R @@ -142,6 +142,7 @@ running <- function( #' @param upstream_only Deprecated. #' @examples #' \dontrun{ +#' isolate_example("contain side effects", { #' if (suppressWarnings(require("knitr"))) { #' # Build a plan doomed to fail: #' bad_plan <- drake_plan(x = function_doesnt_exist()) @@ -156,6 +157,7 @@ running <- function( #' e$error #' names(e$error) #' } +#' }) #' } failed <- function( path = NULL, diff --git a/R/api-read.R b/R/api-read.R index d2a1cc682..614d6d893 100644 --- a/R/api-read.R +++ b/R/api-read.R @@ -415,6 +415,8 @@ bind_load_target <- function(target, cache, namespace, envir, verbose) { #' @inheritParams cached #' #' @examples +#' \dontrun{ +#' isolate_example("contain side effects", { #' cache <- storr::storr_environment() # Just for the examples. #' my_plan <- drake_plan( #' target1 = sqrt(1234), @@ -447,6 +449,8 @@ bind_load_target <- function(target, cache, namespace, envir, verbose) { #' make(my_plan, cache = cache, seed = 1234) #' read_drake_seed(cache = cache) #' readd(target2, cache = cache) +#' }) +#' } read_drake_seed <- function( path = NULL, search = NULL, diff --git a/R/api-slice.R b/R/api-slice.R index a555b31f8..6b3c0ecc8 100644 --- a/R/api-slice.R +++ b/R/api-slice.R @@ -35,6 +35,7 @@ #' drake_slice(x, slices = 3, margin = 2, index = 1) #' # In drake, you can split a large dataset over multiple targets. #' \dontrun{ +#' isolate_example("contain side effects", { #' plan <- drake_plan( #' large_data = iris, #' data_split = target( @@ -47,6 +48,7 @@ #' make(plan, cache = cache, session_info = FALSE, verbose = FALSE) #' readd(data_split_1L, cache = cache) #' readd(data_split_2L, cache = cache) +#' }) #' } drake_slice <- function(data, slices, index, margin = 1L, drop = FALSE) { check_drake_slice_args(margin, slices, index) diff --git a/R/api-usedrake.R b/R/api-usedrake.R index 0b4cd2c0e..10d9c0667 100644 --- a/R/api-usedrake.R +++ b/R/api-usedrake.R @@ -19,7 +19,9 @@ #' @export #' @param open Logical, whether to open `make.R` for editing. #' @examples +#' \dontrun{ #' # use_drake(open = FALSE) # nolint +#' } use_drake <- function(open = interactive()) { # Covered in tests/testthat/test-always-skipped.R. # Reason: https://github.com/r-lib/usethis/issues/347 diff --git a/R/drake_plan_helpers.R b/R/drake_plan_helpers.R index e198b798e..157ea03ed 100644 --- a/R/drake_plan_helpers.R +++ b/R/drake_plan_helpers.R @@ -19,7 +19,6 @@ #' ) #' your_plan <- bind_plans(download_plan, analysis_plan) #' your_plan -#' # make(your_plan) # nolint bind_plans <- function(...) { sanitize_plan(drake_bind_rows(...)) } diff --git a/R/drake_plan_keywords.R b/R/drake_plan_keywords.R index fb6081439..6155d6326 100644 --- a/R/drake_plan_keywords.R +++ b/R/drake_plan_keywords.R @@ -185,6 +185,7 @@ file_out <- file_in #' source files supplied to a command in your workflow plan data frame. #' @examples #' \dontrun{ +#' isolate_example("contain side effects", { #' # `knitr_in()` is like `file_in()` #' # except that it analyzes active code chunks in your `knitr` #' # source file and detects non-file dependencies. @@ -204,6 +205,7 @@ file_out <- file_in #' # to analyze the active code chunks. There, it spotted #' # where `small`, `large`, and `coef_regression2_small` #' # were read from the cache using calls to `loadd()` and `readd()`. +#' }) #' } knitr_in <- file_in @@ -317,6 +319,8 @@ no_deps <- function(x = NULL) { #' @seealso [from_plan()] #' @return The environment where `drake` builds targets. #' @examples +#' \dontrun{ +#' isolate_example("contain side effects", { #' plan <- drake_plan( #' large_data_1 = sample.int(1e4), #' large_data_2 = sample.int(1e4), @@ -330,6 +334,8 @@ no_deps <- function(x = NULL) { #' } #' ) #' make(plan, cache = storr::storr_environment(), session_info = FALSE) +#' }) +#' } drake_envir <- function() { envir <- environment() for (i in seq_len(getOption("expressions"))) { diff --git a/R/exec-imports.R b/R/exec-imports.R index cad056946..414e3c33d 100644 --- a/R/exec-imports.R +++ b/R/exec-imports.R @@ -12,8 +12,6 @@ process_imports <- function(config) { #' @keywords internal #' @param import Character, name of an import to process #' @param config [drake_config()] object -#' @examples -#' # Not a user-side function. process_import <- function(import, config) { meta <- drake_meta_(import, config) if (meta$isfile) { diff --git a/R/exec-memory.R b/R/exec-memory.R index 7aaf3f086..b83af8341 100644 --- a/R/exec-memory.R +++ b/R/exec-memory.R @@ -37,8 +37,6 @@ assign_to_envir <- function(target, value, config) { #' @param downstream Optional, character vector of any targets #' assumed to be downstream. #' @param jobs Number of jobs for local parallel computing -#' @examples -#' # Users should use make(). manage_memory <- function(target, config, downstream = NULL, jobs = 1) { stopifnot(length(target) == 1L) if (identical(config$garbage_collection, TRUE)) { diff --git a/R/utils-deprecate.R b/R/utils-deprecate.R index 79bfa77bc..243d50c81 100644 --- a/R/utils-deprecate.R +++ b/R/utils-deprecate.R @@ -3,8 +3,6 @@ #' @keywords internal #' @description Deprecated on 2018-12-12. #' @return A character vector of names of available hash algorithms. -#' @examples -#' # deprecated available_hash_algos <- function() { .Deprecated( new = "", @@ -21,8 +19,6 @@ available_hash_algos <- function() { #' @keywords internal #' @return An `igraph` object. #' @inheritParams drake_config -#' @examples -#' # See ?drake_config for examples. build_drake_graph <- function( plan, targets = plan$target, @@ -93,9 +89,6 @@ build_drake_graph <- function( #' version in the cache and other common values. #' Not always a thread safe operation, so should only be `TRUE` #' on the master process -#' -#' @examples -#' # deprecated configure_cache <- function( cache = drake::get_cache(verbose = verbose), short_hash_algo = drake::default_short_hash_algo(cache = cache), @@ -155,8 +148,6 @@ configure_cache <- function( #' supplying a long hash algorithm, #' `default_long_hash_algo(cache)` is the long #' hash algorithm that drake picks for you. -#' @examples -#' # deprecated default_long_hash_algo <- function(cache = NULL) { .Deprecated( new = "", @@ -189,8 +180,6 @@ default_long_hash_algo <- function(cache = NULL) { #' supplying a short hash algorithm, #' `default_short_hash_algo(cache)` is the short #' hash algorithm that drake picks for you. -#' @examples -#' # deprecated default_short_hash_algo <- function(cache = NULL) { .Deprecated( new = "", @@ -235,15 +224,6 @@ deprecate_force <- function(force) { #' @param reverse Logical, whether to compute reverse dependencies #' (targets immediately downstream) instead of ordinary dependencies. #' @return Names of dependencies listed by type (object, input file, etc). -#' @examples -#' \dontrun{ -#' isolate_example("Quarantine side effects.", { -#' load_mtcars_example() # Get the code with drake_example("mtcars"). -#' config <- drake_config(my_plan) -#' deps_targets("regression1_small", config = config) -#' deps_targets(c("small", "large"), config = config, reverse = TRUE) -#' }) -#' } deps_targets <- function( targets, config, @@ -267,8 +247,6 @@ deps_targets <- function( #' @keywords internal #' @inheritParams drake_hpc_template_file #' @param example Name of template file. -#' @examples -#' # See drake_hpc_template_file() for examples. drake_batchtools_tmpl_file <- function( example = drake::drake_hpc_template_files(), to = getwd(), @@ -293,8 +271,6 @@ drake_batchtools_tmpl_file <- function( #' @keywords internal #' @return [sessionInfo()] of the last call to [make()] #' @inheritParams cached -#' @examples -#' # See ?drake_get_session_info for examples. drake_session <- function( path = getwd(), search = TRUE, @@ -321,8 +297,6 @@ drake_session <- function( #' @description Deprecated on 2018-12-12 #' @return A character vector naming a hash algorithm. #' @inheritParams cached -#' @examples -#' # deprecated long_hash <- function( cache = drake::get_cache(verbose = verbose), verbose = 1L @@ -349,8 +323,6 @@ long_hash <- function( #' @return A `ggplot2` object, which you can modify with more layers, #' show with `plot()`, or save as a file with `ggsave()`. #' @inheritParams render_drake_ggraph -#' @examples -#' # See render_drake_ggraph() render_static_drake_graph <- function( graph_info, main = graph_info$default_title @@ -372,8 +344,6 @@ render_static_drake_graph <- function( #' @description Deprecated on 2018-12-12. #' @return A character vector naming a hash algorithm. #' @inheritParams cached -#' @examples -#' # deprecated short_hash <- function( cache = drake::get_cache(verbose = verbose), verbose = 1L @@ -401,8 +371,6 @@ short_hash <- function( #' @return A `ggplot2` object, which you can modify with more layers, #' show with `plot()`, or save as a file with `ggsave()`. #' @inheritParams drake_ggraph -#' @examples -#' # See drake_ggraph() static_drake_graph <- function( config, build_times = "build", @@ -453,8 +421,6 @@ static_drake_graph <- function( #' is outdated or up to date. #' @details Deprecated on 2018-07-22. #' @return A character vector with the names of the old triggers. -#' @examples -#' # Deprecated. See the trigger() function instead (singular). triggers <- function() { .Deprecated( new = "", @@ -543,14 +509,6 @@ deprecate_targets_only <- function(targets_only) { #' @param force Deprecated. #' @keywords internal #' @details Deprecated 2018-12-31. -#' @examples -#' \dontrun{ -#' # The code for this example is hosted at -#' # https://github.com/wlandau/drake-examples/tree/master/main -#' # You can download it with drake_example("main") -#' # or watch a video tutorial about it at -#' # https://ropenscilabs.github.io/drake-manual/. -#' } load_main_example <- function( envir = parent.frame(), report_file = "report.Rmd", @@ -595,14 +553,6 @@ load_main_example <- function( #' @return Nothing. #' @keywords internal #' @details Deprecated 2018-12-31. -#' @examples -#' \dontrun{ -#' # The code for this example is hosted at -#' # https://github.com/wlandau/drake-examples/tree/master/main -#' # You can download it with drake_example("main") -#' # or watch a video tutorial about it at -#' # https://ropenscilabs.github.io/drake-manual/. -#' } clean_main_example <- function() { deprecate_force(force) .Deprecated( @@ -637,8 +587,6 @@ default_verbose <- function() { #' @param x Character vector or object to be coerced to character. #' @param single Add single quotes if `TRUE` #' and double quotes otherwise. -#' @examples -#' # deprecated drake_quotes <- function(x = NULL, single = FALSE) { .Deprecated( new = "", @@ -665,8 +613,6 @@ drake_quotes <- function(x = NULL, single = FALSE) { #' or trailing escaped quotes around #' the elements. #' @param x Character vector. -#' @examples -#' # deprecated drake_unquote <- function(x = NULL) { .Deprecated( new = "", @@ -682,8 +628,6 @@ drake_unquote <- function(x = NULL) { #' @keywords internal #' @return A character vector. #' @param ... Unquoted symbols to turn into character strings. -#' @examples -#' # deprecated drake_strings <- function(...) { .Deprecated( new = "", @@ -770,8 +714,6 @@ find_project <- function(path = getwd()) { #' @return `args` for `system2(command, args)` #' @inheritParams drake_config #' @param jobs Number of jobs. -#' @examples -#' # deprecated default_Makefile_args <- function(jobs, verbose) { .Deprecated( new = "", @@ -793,8 +735,6 @@ default_Makefile_args <- function(jobs, verbose) { #' @keywords internal #' @return A character scalar #' @export -#' @examples -#' # deprecated default_Makefile_command <- function() { .Deprecated( new = "", @@ -815,8 +755,6 @@ default_Makefile_command <- function() { #' @param recipe_command Character scalar. #' @param target Character scalar. #' @param cache_path Character scalar. -#' @examples -#' # deprecated Makefile_recipe <- function( # nolint recipe_command = drake::default_recipe_command(), target = "your_target", @@ -838,8 +776,6 @@ Makefile_recipe <- function( # nolint #' @keywords internal #' @description 2019-01-02 #' @return A character scalar with the default recipe command. -#' @examples -#' # deprecated default_recipe_command <- function() { .Deprecated( new = "", @@ -857,8 +793,6 @@ default_recipe_command <- function() { #' @keywords internal #' @description 2019-01-02 #' @return The R recipe wildcard. -#' @examples -#' # deprecated r_recipe_wildcard <- function() { .Deprecated( new = "", @@ -877,8 +811,6 @@ r_recipe_wildcard <- function() { #' @keywords internal #' @return character vector #' @param distributed_only Logical. -#' @examples -#' # deprecated parallelism_choices <- function(distributed_only = FALSE) { .Deprecated( new = "", @@ -911,8 +843,6 @@ parallelism_choices <- function(distributed_only = FALSE) { #' @return logical #' @param path Character. #' @param overwrite Logical. -#' @examples -#' # deprecated shell_file <- function( path = "shell.sh", overwrite = FALSE @@ -933,8 +863,6 @@ shell_file <- function( #' @export #' @keywords internal #' @return character -#' @examples -#' # deprecated default_parallelism <- function() { .Deprecated( new = "", @@ -953,8 +881,6 @@ default_parallelism <- function() { #' @seealso [make()], [drake_config()] #' @return nothing #' @param config A configuration list returned by [drake_config()]. -#' @examples -#' # deprecated make_imports <- function(config) { .Deprecated( new = "make", @@ -975,8 +901,6 @@ make_imports <- function(config) { #' @seealso [make()], [drake_config()] #' @return nothing #' @param config A configuration list returned by [drake_config()]. -#' @examples -#' # deprecated make_targets <- function(config) { .Deprecated( new = "make", @@ -997,8 +921,6 @@ make_targets <- function(config) { #' @seealso [make()], [drake_config()] #' @return nothing #' @param config A configuration list returned by [drake_config()]. -#' @examples -#' # deprecated make_with_config <- function(config) { .Deprecated( new = "make", @@ -1018,8 +940,6 @@ make_with_config <- function(config) { #' @export #' @keywords internal #' @inheritParams cached -#' @examples -#' # deprecated read_drake_config <- function( path = getwd(), search = TRUE, @@ -1049,8 +969,6 @@ read_drake_config <- function( #' @export #' @keywords internal #' @inheritParams cached -#' @examples -#' # deprecated read_drake_graph <- function( path = getwd(), search = TRUE, @@ -1078,8 +996,6 @@ read_drake_graph <- function( #' @export #' @keywords internal #' @inheritParams cached -#' @examples -#' # deprecated read_drake_plan <- function( path = getwd(), search = TRUE, @@ -1153,8 +1069,6 @@ imported <- function( #' @param graph An igraph object. #' @param to Character vector of vertices. #' @param jobs Number of jobs for parallelism. -#' @examples -#' # deprecated prune_drake_graph <- function( graph, to = igraph::V(graph)$name, jobs = 1 ) { @@ -1470,8 +1384,6 @@ target_namespaces <- function( #' to make the datasets. #' @param sep character Scalar, delimiter for creating #' the names of new targets. -#' @examples -#' # Deprecated plan_analyses <- function(plan, datasets, sep = "_") { .Deprecated( new = "", @@ -1513,8 +1425,6 @@ plan_analyses <- function(plan, datasets, sep = "_") { #' for more. #' @param sep Character scalar, delimiter for creating the #' new target names. -#' @examples -#' # Deprecated plan_summaries <- function( plan, analyses, @@ -1762,8 +1672,6 @@ this_cache <- function( #' output will include the hashes of both targets and imports. #' @keywords internal #' @return There is no return value, but a log file is generated. -#' @examples -#' # Deprecated drake_cache_log_file <- function( file = "drake_cache.log", path = getwd(), @@ -1849,91 +1757,6 @@ drake_cache_log_file <- function( #' of the new targets generated. For example, in #' `evaluate_plan(drake_plan(x = sqrt(y__)), list(y__ = 1:2), sep = ".")`, #' the names of the new targets are `x.1` and `x.2`. -#' -#' @examples -#' \dontrun{ -#' suppressWarnings({ -#' # Create the part of the workflow plan for the datasets. -#' datasets <- drake_plan( -#' small = simulate(5), -#' large = simulate(50) -#' ) -#' # Create a template workflow plan for the analyses. -#' methods <- drake_plan( -#' regression1 = reg1(dataset__), -#' regression2 = reg2(dataset__) -#' ) -#' # Evaluate the wildcards in the template -#' # to produce the actual part of the workflow plan -#' # that encodes the analyses of the datasets. -#' # Create one analysis for each combination of dataset and method. -#' evaluate_plan( -#' methods, -#' wildcard = "dataset__", -#' values = datasets$target -#' ) -#' # Only choose some combinations of dataset and analysis method. -#' ans <- evaluate_plan( -#' methods, -#' wildcard = "dataset__", -#' values = datasets$target, -#' expand = FALSE -#' ) -#' ans -#' # For the complete workflow plan, row bind the pieces together. -#' my_plan <- rbind(datasets, ans) -#' my_plan -#' # Wildcards for evaluate_plan() do not need the double-underscore suffix. -#' # Any valid symbol will do. -#' plan <- drake_plan( -#' numbers = sample.int(n = `{Number}`, size = ..size) -#' ) -#' evaluate_plan( -#' plan, -#' rules = list( -#' "`{Number}`" = c(10, 13), -#' ..size = c(3, 4) -#' ) -#' ) -#' # Workflow plans can have multiple wildcards. -#' # Each combination of wildcard values will be used -#' # Except when expand is FALSE. -#' x <- drake_plan(draws = sample.int(n = N, size = Size)) -#' evaluate_plan(x, rules = list(N = 10:13, Size = 1:2)) -#' # You can use wildcards on columns other than "command" -#' evaluate_plan( -#' drake_plan( -#' x = target("1 + 1", cpu = "any"), -#' y = target("sqrt(4)", cpu = "always"), -#' z = target("sqrt(16)", cpu = "any") -#' ), -#' rules = list(always = 1:2), -#' columns = c("command", "cpu") -#' ) -#' # With the `trace` argument, -#' # you can generate columns that show how the wildcards -#' # were evaluated. -#' plan <- drake_plan(x = sample.int(n__), y = sqrt(n__)) -#' plan <- evaluate_plan(plan, wildcard = "n__", values = 1:2, trace = TRUE) -#' print(plan) -#' # With the `trace` argument, -#' # you can generate columns that show how the wildcards -#' # were evaluated. Then you can visualize the wildcard groups -#' # as clusters. -#' plan <- drake_plan(x = sqrt(n__), y = sample.int(n__)) -#' plan <- evaluate_plan(plan, wildcard = "n__", values = 1:2, trace = TRUE) -#' print(plan) -#' cache <- storr::storr_environment() -#' config <- drake_config(plan, cache = cache) -#' if (requireNamespace("visNetwork", quietly = TRUE)) { -#' vis_drake_graph(config, group = "n__", clusters = "1") -#' vis_drake_graph(config, group = "n__", clusters = c("1", "2")) -#' make(plan, targets = c("x_1", "y_2"), cache = cache) -#' # Optionally cluster on columns supplied by `drake_graph_info()$nodes`. -#' vis_drake_graph(config, group = "status", clusters = "up to date") -#' } -#' }) -#' } evaluate_plan <- function( plan, rules = NULL, @@ -2119,22 +1942,6 @@ check_wildcard_rules <- function(rules) { #' target names and the values to append to create the new #' target names. Only relevant when `rename` is `TRUE`. #' @param sanitize Logical, whether to sanitize the plan. -#' @examples -#' \dontrun{ -#' suppressWarnings({ -#' # Create the part of the workflow plan for the datasets. -#' datasets <- drake_plan( -#' small = simulate(5), -#' large = simulate(50) -#' ) -#' # Create replicates. If you want repeat targets, -#' # this is convenient. -#' expand_plan(datasets, values = c("rep1", "rep2", "rep3")) -#' # Choose whether to rename the targets based on the values. -#' expand_plan(datasets, values = 1:3, rename = TRUE) -#' expand_plan(datasets, values = 1:3, rename = FALSE) -#' }) -#' } expand_plan <- function( plan, values = NULL, rename = TRUE, sep = "_", sanitize = TRUE ) { @@ -2197,37 +2004,6 @@ expand_plan <- function( #' to the output workflow plan data frame. The added columns #' help "trace back" the original settings that went into building #' each target. Similar to the `trace` argument of [drake_plan()]. -#' @examples -#' \dontrun{ -#' suppressWarnings({ -#' # For the full tutorial, visit -#' # https://ropenscilabs.github.io/drake-manual/plans.html#map_plan. -#' my_model_fit <- function(x1, x2, data) { -#' lm(as.formula(paste("mpg ~", x1, "+", x1)), data = data) -#' } -#' covariates <- setdiff(colnames(mtcars), "mpg") -#' args <- t(combn(covariates, 2)) -#' colnames(args) <- c("x1", "x2") -#' # Use tibble::as_tibble(args) for better printing # nolint -#' # Below, stringsAsFactors = FALSE is very important! # nolint -#' args <- as.data.frame(args, stringsAsFactors = FALSE) -#' args$data <- "mtcars" -#' args$data <- rlang::syms(args$data) -#' args$id <- paste0("fit_", args$x1, "_", args$x2) -#' # print(args) # Requires `args` to be a tibble # nolint -#' plan <- map_plan(args, my_model_fit) -#' plan -#' # Consider `trace = TRUE` to include the columns in `args` -#' # in your plan. -#' plan <- map_plan(args, my_model_fit, trace = TRUE) -#' # print(plan) # If you have tibble installed # nolint -#' # And of course, you can execute the plan and -#' # inspect your results. -#' cache <- storr::storr_environment() -#' make(plan, verbose = FALSE, cache = cache) -#' readd(fit_cyl_disp, cache = cache) -#' }) -#' } map_plan <- function( args, fun, @@ -2294,37 +2070,6 @@ map_plan <- function( #' original rows in the `plan` argument. #' If `FALSE`, the output will only include the new #' targets and commands. -#' @examples -#' \dontrun{ -#' suppressWarnings({ -#' # Workflow plan for datasets: -#' datasets <- drake_plan( -#' small = simulate(5), -#' large = simulate(50) -#' ) -#' # Create a new target that brings the datasets together. -#' gather_plan(datasets, target = "my_datasets", append = FALSE) -#' # This time, the new target just appends the rows of 'small' and 'large' -#' # into a single matrix or data frame. -#' gathered <- gather_plan( -#' datasets, -#' target = "aggregated_data", -#' gather = "rbind", -#' append = FALSE -#' ) -#' gathered -#' # For the complete workflow plan, row bind the pieces together. -#' bind_plans(datasets, gathered) -#' # Alternatively, you can set `append = TRUE` to incorporate -#' # the new targets automatically. -#' gather_plan( -#' datasets, -#' target = "aggregated_data", -#' gather = "rbind", -#' append = TRUE -#' ) -#' }) -#' } gather_plan <- function( plan = NULL, target = "target", @@ -2380,35 +2125,6 @@ gather_plan <- function( #' in the output. See the examples for a demonstration. #' @param sep Character scalar, delimiter for creating the names #' of new targets. -#' @examples -#' \dontrun{ -#' suppressWarnings({ -#' plan <- drake_plan( -#' data = get_data(), -#' informal_look = inspect_data(data, mu = mu__), -#' bayes_model = bayesian_model_fit(data, prior_mu = mu__) -#' ) -#' plan <- evaluate_plan(plan, rules = list(mu__ = 1:2), trace = TRUE) -#' plan -#' gather_by(plan, mu___from, gather = "rbind") -#' gather_by(plan, mu___from, append = TRUE) -#' gather_by(plan, mu___from, append = FALSE) -#' gather_by(plan, mu__, mu___from, prefix = "x") -#' gather_by(plan) # Gather everything and append a row. -#' # You can filter out the informal_look_* targets beforehand -#' # if you only want the bayes_model_* ones to be gathered. -#' # The advantage here is that if you also need `append = TRUE`, -#' # only the bayes_model_* targets will be gathered, but -#' # the informal_look_* targets will still be included -#' # in the output. -#' gather_by( -#' plan, -#' mu___from, -#' append = TRUE, -#' filter = mu___from == "bayes_model" -#' ) -#' }) -#' } gather_by <- function( plan, ..., @@ -2485,37 +2201,6 @@ gather_by <- function( #' If `FALSE`, the output will only include the new #' targets and commands. #' @param sep Character scalar, delimiter for creating new target names. -#' @examples -#' \dontrun{ -#' suppressWarnings({ -#' # Workflow plan for datasets: -#' x_plan <- evaluate_plan( -#' drake_plan(x = VALUE), -#' wildcard = "VALUE", -#' values = 1:8 -#' ) -#' x_plan -#' # Create a new target from the sum of the others. -#' reduce_plan(x_plan, target = "x_sum", pairwise = FALSE, append = FALSE) -#' # Optionally include the original rows with `append = TRUE`. -#' reduce_plan(x_plan, target = "x_sum", pairwise = FALSE, append = TRUE) -#' # For memory efficiency and parallel computing, -#' # reduce pairwise: -#' reduce_plan(x_plan, target = "x_sum", pairwise = TRUE, append = FALSE) -#' # Optionally define your own function and use it as the -#' # binary operator in the reduction. -#' x_plan <- evaluate_plan( -#' drake_plan(x = VALUE), -#' wildcard = "VALUE", -#' values = 1:9 -#' ) -#' x_plan -#' reduce_plan( -#' x_plan, target = "x_sum", pairwise = TRUE, -#' begin = "fun(", op = ", ", end = ")" -#' ) -#' }) -#' } reduce_plan <- function( plan = NULL, target = "target", @@ -2589,37 +2274,6 @@ reduce_plan <- function( #' in the output. See the examples for a demonstration. #' @param sep Character scalar, delimiter for creating the names #' of new targets. -#' @examples -#' \dontrun{ -#' suppressWarnings({ -#' plan <- drake_plan( -#' data = get_data(), -#' informal_look = inspect_data(data, mu = mu__), -#' bayes_model = bayesian_model_fit(data, prior_mu = mu__) -#' ) -#' plan <- evaluate_plan(plan, rules = list(mu__ = 1:2), trace = TRUE) -#' plan -#' reduce_by(plan, mu___from, begin = "list(", end = ")", op = ", ") -#' reduce_by(plan, mu__) -#' reduce_by(plan, mu__, append = TRUE) -#' reduce_by(plan, mu__, append = FALSE) -#' reduce_by(plan) # Reduce all the targets. -#' reduce_by(plan, append = FALSE) -#' reduce_by(plan, pairwise = FALSE) -#' # You can filter out the informal_look_* targets beforehand -#' # if you only want the bayes_model_* ones to be reduced. -#' # The advantage here is that if you also need `append = TRUE`, -#' # only the bayes_model_* targets will be reduced, but -#' # the informal_look_* targets will still be included -#' # in the output. -#' reduce_by( -#' plan, -#' mu___from, -#' append = TRUE, -#' filter = mu___from == "bayes_model" -#' ) -#' }) -#' } reduce_by <- function( plan, ..., @@ -2719,22 +2373,6 @@ reduction_pairs <- function(x, pairs = NULL, base_name = "reduced_") { #' - `get_cache(path = "/home/you/my_project/.drake/keys", search = TRUE)` #' @param force Deprecated. #' @param fetch_cache Deprecated. -#' @examples -#' \dontrun{ -#' isolate_example("Quarantine side effects.", { -#' if (suppressWarnings(require("knitr"))) { -#' clean(destroy = TRUE) -#' # No cache is available. -#' get_cache() # NULL -#' load_mtcars_example() # Get the code with drake_example("mtcars"). -#' make(my_plan) # Run the project, build the targets. -#' x <- get_cache() # Now, there is a cache. -#' y <- storr::storr_rds(".drake") # Equivalent. -#' # List the objects readable from the cache with readd(). -#' x$list() -#' } -#' }) -#' } get_cache <- function( path = getwd(), search = TRUE, diff --git a/R/utils-encoding.R b/R/utils-encoding.R index 5f7b71e8b..49ccec11e 100644 --- a/R/utils-encoding.R +++ b/R/utils-encoding.R @@ -105,42 +105,42 @@ display_path <- function(x, config) { } #' @title Tell `drake` that you want information -#' on a *file* (target or import), not an ordinary object. +#' on a *file* (target or import), not an ordinary object. #' @description This function simply wraps literal double quotes around -#' the argument `x` so `drake` knows it is the name of a file. -#' Use when you are calling functions like `deps_code()`: for example, -#' `deps_code(file_store("report.md"))`. See the examples for details. -#' Internally, `drake` wraps the names of file targets/imports -#' inside literal double quotes to avoid confusion between -#' files and generic R objects. +#' the argument `x` so `drake` knows it is the name of a file. +#' Use when you are calling functions like `deps_code()`: for example, +#' `deps_code(file_store("report.md"))`. See the examples for details. +#' Internally, `drake` wraps the names of file targets/imports +#' inside literal double quotes to avoid confusion between +#' files and generic R objects. #' @export #' @return A single-quoted character string: i.e., a filename -#' understandable by drake. +#' understandable by drake. #' @param x Character string to be turned into a filename -#' understandable by drake (i.e., a string with literal -#' single quotes on both ends). +#' understandable by drake (i.e., a string with literal +#' single quotes on both ends). #' @examples -#' # Wraps the string in single quotes. -#' file_store("my_file.rds") # "'my_file.rds'" -#' \dontrun{ -#' isolate_example("contain side effects", { -#' if (suppressWarnings(require("knitr"))) { -#' load_mtcars_example() # Get the code with drake_example("mtcars"). -#' make(my_plan) # Run the workflow to build the targets -#' list.files() # Should include input "report.Rmd" and output "report.md". -#' head(readd(small)) # You can use symbols for ordinary objects. -#' # But if you want to read cached info on files, use `file_store()`. -#' readd(file_store("report.md"), character_only = TRUE) # File fingerprint. -#' deps_code(file_store("report.Rmd")) -#' config <- drake_config(my_plan) -#' deps_profile( -#' file_store("report.Rmd"), -#' config = config, -#' character_only = TRUE -#' ) -#' } -#' }) -#' } +#' # Wraps the string in single quotes. +#' file_store("my_file.rds") # "'my_file.rds'" +#' \dontrun{ +#' isolate_example("contain side effects", { +#' if (suppressWarnings(require("knitr"))) { +#' load_mtcars_example() # Get the code with drake_example("mtcars"). +#' make(my_plan) # Run the workflow to build the targets +#' list.files() # Should include input "report.Rmd" and output "report.md". +#' head(readd(small)) # You can use symbols for ordinary objects. +#' # But if you want to read cached info on files, use `file_store()`. +#' readd(file_store("report.md"), character_only = TRUE) # File fingerprint. +#' deps_code(file_store("report.Rmd")) +#' config <- drake_config(my_plan) +#' deps_profile( +#' file_store("report.Rmd"), +#' config = config, +#' character_only = TRUE +#' ) +#' } +#' }) +#' } file_store <- function(x) { encode_path(x) } diff --git a/R/utils-graphinfo.R b/R/utils-graphinfo.R index 34d16f86e..e95073318 100644 --- a/R/utils-graphinfo.R +++ b/R/utils-graphinfo.R @@ -274,7 +274,7 @@ hover_text <- function(config) { #' # Show the legend nodes used in graph visualizations. #' # For example, you may want to inspect the color palette more closely. #' if (requireNamespace("visNetwork", quietly = TRUE)) { -#' visNetwork::visNetwork(nodes = legend_nodes()) # nolint +#' # visNetwork::visNetwork(nodes = legend_nodes()) # nolint #' } #' } legend_nodes <- function(font_size = 20) { diff --git a/R/vis-console.R b/R/vis-console.R index 478fe9f69..b72272cfd 100644 --- a/R/vis-console.R +++ b/R/vis-console.R @@ -106,11 +106,15 @@ multiline_message <- function(x) { #' `target` as a symbol (`FALSE`) or character vector #' (`TRUE`). #' @examples +#' \dontrun{ +#' isolate_example("contain side effects", { #' plan <- drake_plan(x = sample.int(15)) #' cache <- storr::storr_environment() # custom in-memory cache #' make(plan, cache = cache) #' config <- drake_config(plan, cache = cache) #' show_source(x, config) +#' }) +#' } show_source <- function(target, config, character_only = FALSE) { if (!character_only) { target <- as.character(substitute(target)) diff --git a/man/Makefile_recipe.Rd b/man/Makefile_recipe.Rd index 9565a501b..a1bfce88c 100644 --- a/man/Makefile_recipe.Rd +++ b/man/Makefile_recipe.Rd @@ -20,7 +20,4 @@ A character scalar \description{ 2019-01-03 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/available_hash_algos.Rd b/man/available_hash_algos.Rd index 5c8954690..39d115896 100644 --- a/man/available_hash_algos.Rd +++ b/man/available_hash_algos.Rd @@ -12,7 +12,4 @@ A character vector of names of available hash algorithms. \description{ Deprecated on 2018-12-12. } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/bind_plans.Rd b/man/bind_plans.Rd index da5144001..f91bc6fc2 100644 --- a/man/bind_plans.Rd +++ b/man/bind_plans.Rd @@ -28,7 +28,6 @@ analysis_plan <- drake_plan( ) your_plan <- bind_plans(download_plan, analysis_plan) your_plan -# make(your_plan) # nolint } \seealso{ \code{\link[=drake_plan]{drake_plan()}}, \code{\link[=make]{make()}} diff --git a/man/build_drake_graph.Rd b/man/build_drake_graph.Rd index f005494f3..4d10a0777 100644 --- a/man/build_drake_graph.Rd +++ b/man/build_drake_graph.Rd @@ -79,7 +79,4 @@ Use \code{\link[=drake_config]{drake_config()}} instead. \details{ Deprecated on 2018-11-02. } -\examples{ -# See ?drake_config for examples. -} \keyword{internal} diff --git a/man/clean_main_example.Rd b/man/clean_main_example.Rd index 3b55e6b6f..793f7fa60 100644 --- a/man/clean_main_example.Rd +++ b/man/clean_main_example.Rd @@ -19,13 +19,4 @@ in the current working directory. Your working directory \details{ Deprecated 2018-12-31. } -\examples{ -\dontrun{ -# The code for this example is hosted at -# https://github.com/wlandau/drake-examples/tree/master/main -# You can download it with drake_example("main") -# or watch a video tutorial about it at -# https://ropenscilabs.github.io/drake-manual/. -} -} \keyword{internal} diff --git a/man/configure_cache.Rd b/man/configure_cache.Rd index 3215ba144..7df77baab 100644 --- a/man/configure_cache.Rd +++ b/man/configure_cache.Rd @@ -59,7 +59,4 @@ so we no longer need this configuration step. \details{ Deprecated on 2018-12-12. } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/default_Makefile_args.Rd b/man/default_Makefile_args.Rd index 952849c2b..eb082e3eb 100644 --- a/man/default_Makefile_args.Rd +++ b/man/default_Makefile_args.Rd @@ -22,7 +22,4 @@ default_Makefile_args(jobs, verbose) \description{ 2019-01-03 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/default_Makefile_command.Rd b/man/default_Makefile_command.Rd index a33af66e0..b5d74450f 100644 --- a/man/default_Makefile_command.Rd +++ b/man/default_Makefile_command.Rd @@ -12,7 +12,4 @@ A character scalar \description{ 2019-01-03 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/default_long_hash_algo.Rd b/man/default_long_hash_algo.Rd index 2ade266a1..1d1b77e78 100644 --- a/man/default_long_hash_algo.Rd +++ b/man/default_long_hash_algo.Rd @@ -22,7 +22,4 @@ Deprecated. drake now only uses one hash algorithm per cache. \details{ Deprecated on 2018-12-12 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/default_parallelism.Rd b/man/default_parallelism.Rd index 451b95ae6..bf5d27451 100644 --- a/man/default_parallelism.Rd +++ b/man/default_parallelism.Rd @@ -12,7 +12,4 @@ character \description{ 2019-01-02 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/default_recipe_command.Rd b/man/default_recipe_command.Rd index 1846646d8..50475af69 100644 --- a/man/default_recipe_command.Rd +++ b/man/default_recipe_command.Rd @@ -12,7 +12,4 @@ A character scalar with the default recipe command. \description{ 2019-01-02 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/default_short_hash_algo.Rd b/man/default_short_hash_algo.Rd index 43b0e8cde..69db680ea 100644 --- a/man/default_short_hash_algo.Rd +++ b/man/default_short_hash_algo.Rd @@ -22,7 +22,4 @@ Deprecated. drake now only uses one hash algorithm per cache. \details{ Deprecated on 2018-12-12 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/deps_targets.Rd b/man/deps_targets.Rd index bd5bd2295..0e6fd7903 100644 --- a/man/deps_targets.Rd +++ b/man/deps_targets.Rd @@ -23,14 +23,4 @@ Deprecated. Use \code{\link[=deps_target]{deps_target()}} (singular) instead. \details{ Deprecated on 2018-08-30. } -\examples{ -\dontrun{ -isolate_example("Quarantine side effects.", { -load_mtcars_example() # Get the code with drake_example("mtcars"). -config <- drake_config(my_plan) -deps_targets("regression1_small", config = config) -deps_targets(c("small", "large"), config = config, reverse = TRUE) -}) -} -} \keyword{internal} diff --git a/man/drake_batchtools_tmpl_file.Rd b/man/drake_batchtools_tmpl_file.Rd index aaf1f2acb..1ca1fbc08 100644 --- a/man/drake_batchtools_tmpl_file.Rd +++ b/man/drake_batchtools_tmpl_file.Rd @@ -21,7 +21,4 @@ Deprecated. Use \code{\link[=drake_hpc_template_file]{drake_hpc_template_file()} \details{ Deprecated on 2018-06-27. } -\examples{ -# See drake_hpc_template_file() for examples. -} \keyword{internal} diff --git a/man/drake_cache_log_file.Rd b/man/drake_cache_log_file.Rd index 90e9f2c0b..3d5c81dfc 100644 --- a/man/drake_cache_log_file.Rd +++ b/man/drake_cache_log_file.Rd @@ -45,9 +45,6 @@ Calling this function to create a log file and later calling \code{make()} with the \code{cache_log_file} argument to create the cache log. This way ensures that the log is always up to date with \code{make()} results. } -\examples{ -# Deprecated -} \seealso{ \code{\link[=drake_cache_log]{drake_cache_log()}}, \code{\link[=make]{make()}}, \code{\link[=get_cache]{get_cache()}} } diff --git a/man/drake_envir.Rd b/man/drake_envir.Rd index b0a887006..20e033817 100644 --- a/man/drake_envir.Rd +++ b/man/drake_envir.Rd @@ -40,6 +40,8 @@ Intended for advanced custom memory management. } \examples{ +\dontrun{ +isolate_example("contain side effects", { plan <- drake_plan( large_data_1 = sample.int(1e4), large_data_2 = sample.int(1e4), @@ -53,6 +55,8 @@ plan <- drake_plan( } ) make(plan, cache = storr::storr_environment(), session_info = FALSE) +}) +} } \seealso{ \code{\link[=from_plan]{from_plan()}} diff --git a/man/drake_quotes.Rd b/man/drake_quotes.Rd index 9c29fd1c8..5df60999a 100644 --- a/man/drake_quotes.Rd +++ b/man/drake_quotes.Rd @@ -18,7 +18,4 @@ Character vector with quotes around it. \description{ Deprecated on 2019-01-01 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/drake_session.Rd b/man/drake_session.Rd index 3a2901ee0..962e06aee 100644 --- a/man/drake_session.Rd +++ b/man/drake_session.Rd @@ -34,7 +34,4 @@ Deprecated. Use \code{\link[=drake_get_session_info]{drake_get_session_info()}} \details{ Deprecated on 2018-12-06. } -\examples{ -# See ?drake_get_session_info for examples. -} \keyword{internal} diff --git a/man/drake_slice.Rd b/man/drake_slice.Rd index c981bc8d9..a8615a335 100644 --- a/man/drake_slice.Rd +++ b/man/drake_slice.Rd @@ -50,6 +50,7 @@ drake_slice(x, slices = 3, index = 3) drake_slice(x, slices = 3, margin = 2, index = 1) # In drake, you can split a large dataset over multiple targets. \dontrun{ +isolate_example("contain side effects", { plan <- drake_plan( large_data = iris, data_split = target( @@ -62,5 +63,6 @@ cache <- storr::storr_environment() make(plan, cache = cache, session_info = FALSE, verbose = FALSE) readd(data_split_1L, cache = cache) readd(data_split_2L, cache = cache) +}) } } diff --git a/man/drake_strings.Rd b/man/drake_strings.Rd index ade6e8621..80e5ca6a4 100644 --- a/man/drake_strings.Rd +++ b/man/drake_strings.Rd @@ -15,7 +15,4 @@ A character vector. \description{ Deprecated on 2019-01-01 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/drake_unquote.Rd b/man/drake_unquote.Rd index ff7ccfc15..c35f7d6c7 100644 --- a/man/drake_unquote.Rd +++ b/man/drake_unquote.Rd @@ -18,7 +18,4 @@ the elements. \description{ Deprecated on 2019-01-01 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/evaluate_plan.Rd b/man/evaluate_plan.Rd index f380ded2a..6fdc0180d 100644 --- a/man/evaluate_plan.Rd +++ b/man/evaluate_plan.Rd @@ -74,91 +74,6 @@ which overrules \code{wildcard} and \code{values} if not \code{NULL}. Here, \code{rules} should be a list with wildcards as names and vectors of possible values as list elements. } -\examples{ -\dontrun{ -suppressWarnings({ -# Create the part of the workflow plan for the datasets. -datasets <- drake_plan( - small = simulate(5), - large = simulate(50) -) -# Create a template workflow plan for the analyses. -methods <- drake_plan( - regression1 = reg1(dataset__), - regression2 = reg2(dataset__) -) -# Evaluate the wildcards in the template -# to produce the actual part of the workflow plan -# that encodes the analyses of the datasets. -# Create one analysis for each combination of dataset and method. -evaluate_plan( - methods, - wildcard = "dataset__", - values = datasets$target -) -# Only choose some combinations of dataset and analysis method. -ans <- evaluate_plan( - methods, - wildcard = "dataset__", - values = datasets$target, - expand = FALSE -) -ans -# For the complete workflow plan, row bind the pieces together. -my_plan <- rbind(datasets, ans) -my_plan -# Wildcards for evaluate_plan() do not need the double-underscore suffix. -# Any valid symbol will do. -plan <- drake_plan( - numbers = sample.int(n = `{Number}`, size = ..size) -) -evaluate_plan( - plan, - rules = list( - "`{Number}`" = c(10, 13), - ..size = c(3, 4) - ) -) -# Workflow plans can have multiple wildcards. -# Each combination of wildcard values will be used -# Except when expand is FALSE. -x <- drake_plan(draws = sample.int(n = N, size = Size)) -evaluate_plan(x, rules = list(N = 10:13, Size = 1:2)) -# You can use wildcards on columns other than "command" -evaluate_plan( - drake_plan( - x = target("1 + 1", cpu = "any"), - y = target("sqrt(4)", cpu = "always"), - z = target("sqrt(16)", cpu = "any") - ), - rules = list(always = 1:2), - columns = c("command", "cpu") -) -# With the `trace` argument, -# you can generate columns that show how the wildcards -# were evaluated. -plan <- drake_plan(x = sample.int(n__), y = sqrt(n__)) -plan <- evaluate_plan(plan, wildcard = "n__", values = 1:2, trace = TRUE) -print(plan) -# With the `trace` argument, -# you can generate columns that show how the wildcards -# were evaluated. Then you can visualize the wildcard groups -# as clusters. -plan <- drake_plan(x = sqrt(n__), y = sample.int(n__)) -plan <- evaluate_plan(plan, wildcard = "n__", values = 1:2, trace = TRUE) -print(plan) -cache <- storr::storr_environment() -config <- drake_config(plan, cache = cache) -if (requireNamespace("visNetwork", quietly = TRUE)) { -vis_drake_graph(config, group = "n__", clusters = "1") -vis_drake_graph(config, group = "n__", clusters = c("1", "2")) -make(plan, targets = c("x_1", "y_2"), cache = cache) -# Optionally cluster on columns supplied by `drake_graph_info()$nodes`. -vis_drake_graph(config, group = "status", clusters = "up to date") -} -}) -} -} \seealso{ \code{\link[=drake_plan]{drake_plan()}} } diff --git a/man/expand_plan.Rd b/man/expand_plan.Rd index 0f0077dce..1dc516af5 100644 --- a/man/expand_plan.Rd +++ b/man/expand_plan.Rd @@ -36,23 +36,6 @@ Duplicates the rows of a workflow plan data frame. Prefixes are appended to the new target names so targets still have unique names. } -\examples{ -\dontrun{ -suppressWarnings({ -# Create the part of the workflow plan for the datasets. -datasets <- drake_plan( - small = simulate(5), - large = simulate(50) -) -# Create replicates. If you want repeat targets, -# this is convenient. -expand_plan(datasets, values = c("rep1", "rep2", "rep3")) -# Choose whether to rename the targets based on the values. -expand_plan(datasets, values = 1:3, rename = TRUE) -expand_plan(datasets, values = 1:3, rename = FALSE) -}) -} -} \seealso{ \code{\link[=drake_plan]{drake_plan()}} } diff --git a/man/expose_imports.Rd b/man/expose_imports.Rd index 6685a12d0..936625fcc 100644 --- a/man/expose_imports.Rd +++ b/man/expose_imports.Rd @@ -49,6 +49,7 @@ for the idea that makes this function work. } \examples{ \dontrun{ +isolate_example("contain side effects", { # Suppose you have a workflow that uses the `digest()` function, # which computes the hash of an object. @@ -101,5 +102,6 @@ g <- function(x) { } config <- drake_config(plan, cache = cache, history = FALSE) tracked(config) +}) } } diff --git a/man/failed.Rd b/man/failed.Rd index 4d189c9e0..afa71f6af 100644 --- a/man/failed.Rd +++ b/man/failed.Rd @@ -36,6 +36,7 @@ for ordinary error messages printed to the console. } \examples{ \dontrun{ +isolate_example("contain side effects", { if (suppressWarnings(require("knitr"))) { # Build a plan doomed to fail: bad_plan <- drake_plan(x = function_doesnt_exist()) @@ -50,6 +51,7 @@ names(e) e$error names(e$error) } +}) } } \seealso{ diff --git a/man/file_store.Rd b/man/file_store.Rd index 7272b784b..87ce5b6c9 100644 --- a/man/file_store.Rd +++ b/man/file_store.Rd @@ -26,25 +26,25 @@ inside literal double quotes to avoid confusion between files and generic R objects. } \examples{ - # Wraps the string in single quotes. - file_store("my_file.rds") # "'my_file.rds'" - \dontrun{ - isolate_example("contain side effects", { - if (suppressWarnings(require("knitr"))) { - load_mtcars_example() # Get the code with drake_example("mtcars"). - make(my_plan) # Run the workflow to build the targets - list.files() # Should include input "report.Rmd" and output "report.md". - head(readd(small)) # You can use symbols for ordinary objects. - # But if you want to read cached info on files, use `file_store()`. - readd(file_store("report.md"), character_only = TRUE) # File fingerprint. - deps_code(file_store("report.Rmd")) - config <- drake_config(my_plan) - deps_profile( - file_store("report.Rmd"), - config = config, - character_only = TRUE - ) - } - }) - } +# Wraps the string in single quotes. +file_store("my_file.rds") # "'my_file.rds'" +\dontrun{ +isolate_example("contain side effects", { +if (suppressWarnings(require("knitr"))) { +load_mtcars_example() # Get the code with drake_example("mtcars"). +make(my_plan) # Run the workflow to build the targets +list.files() # Should include input "report.Rmd" and output "report.md". +head(readd(small)) # You can use symbols for ordinary objects. +# But if you want to read cached info on files, use `file_store()`. +readd(file_store("report.md"), character_only = TRUE) # File fingerprint. +deps_code(file_store("report.Rmd")) +config <- drake_config(my_plan) +deps_profile( + file_store("report.Rmd"), + config = config, + character_only = TRUE +) +} +}) +} } diff --git a/man/gather_by.Rd b/man/gather_by.Rd index 129dc706b..4c1993bfc 100644 --- a/man/gather_by.Rd +++ b/man/gather_by.Rd @@ -52,36 +52,6 @@ Perform several calls to \code{gather_plan()} based on groupings from columns in the plan, and then row-bind the new targets to the plan. } -\examples{ -\dontrun{ -suppressWarnings({ -plan <- drake_plan( - data = get_data(), - informal_look = inspect_data(data, mu = mu__), - bayes_model = bayesian_model_fit(data, prior_mu = mu__) -) -plan <- evaluate_plan(plan, rules = list(mu__ = 1:2), trace = TRUE) -plan -gather_by(plan, mu___from, gather = "rbind") -gather_by(plan, mu___from, append = TRUE) -gather_by(plan, mu___from, append = FALSE) -gather_by(plan, mu__, mu___from, prefix = "x") -gather_by(plan) # Gather everything and append a row. -# You can filter out the informal_look_* targets beforehand -# if you only want the bayes_model_* ones to be gathered. -# The advantage here is that if you also need `append = TRUE`, -# only the bayes_model_* targets will be gathered, but -# the informal_look_* targets will still be included -# in the output. -gather_by( - plan, - mu___from, - append = TRUE, - filter = mu___from == "bayes_model" -) -}) -} -} \seealso{ \code{\link[=drake_plan]{drake_plan()}} } diff --git a/man/gather_plan.Rd b/man/gather_plan.Rd index dd9074bc1..069934678 100644 --- a/man/gather_plan.Rd +++ b/man/gather_plan.Rd @@ -36,38 +36,6 @@ for the details. Creates a new workflow plan to aggregate existing targets in the supplied plan. } -\examples{ -\dontrun{ -suppressWarnings({ -# Workflow plan for datasets: -datasets <- drake_plan( - small = simulate(5), - large = simulate(50) -) -# Create a new target that brings the datasets together. -gather_plan(datasets, target = "my_datasets", append = FALSE) -# This time, the new target just appends the rows of 'small' and 'large' -# into a single matrix or data frame. -gathered <- gather_plan( - datasets, - target = "aggregated_data", - gather = "rbind", - append = FALSE -) -gathered -# For the complete workflow plan, row bind the pieces together. -bind_plans(datasets, gathered) -# Alternatively, you can set `append = TRUE` to incorporate -# the new targets automatically. -gather_plan( - datasets, - target = "aggregated_data", - gather = "rbind", - append = TRUE -) -}) -} -} \seealso{ \code{\link[=drake_plan]{drake_plan()}} } diff --git a/man/get_cache.Rd b/man/get_cache.Rd index d36f10cb0..765e961cb 100644 --- a/man/get_cache.Rd +++ b/man/get_cache.Rd @@ -58,21 +58,4 @@ Use \code{\link[=drake_cache]{drake_cache()}} instead. \details{ Deprecated on 2019-05-25. } -\examples{ -\dontrun{ -isolate_example("Quarantine side effects.", { -if (suppressWarnings(require("knitr"))) { -clean(destroy = TRUE) -# No cache is available. -get_cache() # NULL -load_mtcars_example() # Get the code with drake_example("mtcars"). -make(my_plan) # Run the project, build the targets. -x <- get_cache() # Now, there is a cache. -y <- storr::storr_rds(".drake") # Equivalent. -# List the objects readable from the cache with readd(). -x$list() -} -}) -} -} \keyword{internal} diff --git a/man/knitr_in.Rd b/man/knitr_in.Rd index 4b54cadf4..3540e601b 100644 --- a/man/knitr_in.Rd +++ b/man/knitr_in.Rd @@ -51,6 +51,7 @@ Intended for advanced custom memory management. \examples{ \dontrun{ +isolate_example("contain side effects", { # `knitr_in()` is like `file_in()` # except that it analyzes active code chunks in your `knitr` # source file and detects non-file dependencies. @@ -70,6 +71,7 @@ make(my_plan) # to analyze the active code chunks. There, it spotted # where `small`, `large`, and `coef_regression2_small` # were read from the cache using calls to `loadd()` and `readd()`. +}) } } \seealso{ diff --git a/man/legend_nodes.Rd b/man/legend_nodes.Rd index 4565897cc..9b9117e73 100644 --- a/man/legend_nodes.Rd +++ b/man/legend_nodes.Rd @@ -24,7 +24,7 @@ in the graph visualizations. # Show the legend nodes used in graph visualizations. # For example, you may want to inspect the color palette more closely. if (requireNamespace("visNetwork", quietly = TRUE)) { -visNetwork::visNetwork(nodes = legend_nodes()) # nolint +# visNetwork::visNetwork(nodes = legend_nodes()) # nolint } } } diff --git a/man/load_main_example.Rd b/man/load_main_example.Rd index b767789ad..079065552 100644 --- a/man/load_main_example.Rd +++ b/man/load_main_example.Rd @@ -33,13 +33,4 @@ the files \code{report.Rmd} and \code{raw_data.xlsx}. \details{ Deprecated 2018-12-31. } -\examples{ -\dontrun{ -# The code for this example is hosted at -# https://github.com/wlandau/drake-examples/tree/master/main -# You can download it with drake_example("main") -# or watch a video tutorial about it at -# https://ropenscilabs.github.io/drake-manual/. -} -} \keyword{internal} diff --git a/man/long_hash.Rd b/man/long_hash.Rd index 68ebf2ae7..61ca978a4 100644 --- a/man/long_hash.Rd +++ b/man/long_hash.Rd @@ -23,7 +23,4 @@ A character vector naming a hash algorithm. \description{ Deprecated on 2018-12-12 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/make_imports.Rd b/man/make_imports.Rd index a12ecb606..304a73f8e 100644 --- a/man/make_imports.Rd +++ b/man/make_imports.Rd @@ -15,9 +15,6 @@ nothing \description{ Deprecated on 2019-01-04 } -\examples{ -# deprecated -} \seealso{ \code{\link[=make]{make()}}, \code{\link[=drake_config]{drake_config()}} } diff --git a/man/make_targets.Rd b/man/make_targets.Rd index b743d869e..8e3dacd08 100644 --- a/man/make_targets.Rd +++ b/man/make_targets.Rd @@ -15,9 +15,6 @@ nothing \description{ Deprecated on 2019-01-04 } -\examples{ -# deprecated -} \seealso{ \code{\link[=make]{make()}}, \code{\link[=drake_config]{drake_config()}} } diff --git a/man/make_with_config.Rd b/man/make_with_config.Rd index e0f28dc67..57c5a9efb 100644 --- a/man/make_with_config.Rd +++ b/man/make_with_config.Rd @@ -15,9 +15,6 @@ nothing \description{ Deprecated on 2019-01-04 } -\examples{ -# deprecated -} \seealso{ \code{\link[=make]{make()}}, \code{\link[=drake_config]{drake_config()}} } diff --git a/man/manage_memory.Rd b/man/manage_memory.Rd index b536e5cb4..6e6f50d11 100644 --- a/man/manage_memory.Rd +++ b/man/manage_memory.Rd @@ -23,7 +23,4 @@ Nothing. Load/unload a target's dependencies. Not a user-side function. } -\examples{ -# Users should use make(). -} \keyword{internal} diff --git a/man/map_plan.Rd b/man/map_plan.Rd index f7a7cb894..3ed01cca0 100644 --- a/man/map_plan.Rd +++ b/man/map_plan.Rd @@ -47,38 +47,6 @@ it takes a function name and a grid of arguments, and writes out all the commands calls to apply the function to each row of arguments. } -\examples{ -\dontrun{ -suppressWarnings({ -# For the full tutorial, visit -# https://ropenscilabs.github.io/drake-manual/plans.html#map_plan. -my_model_fit <- function(x1, x2, data) { - lm(as.formula(paste("mpg ~", x1, "+", x1)), data = data) -} -covariates <- setdiff(colnames(mtcars), "mpg") -args <- t(combn(covariates, 2)) -colnames(args) <- c("x1", "x2") -# Use tibble::as_tibble(args) for better printing # nolint -# Below, stringsAsFactors = FALSE is very important! # nolint -args <- as.data.frame(args, stringsAsFactors = FALSE) -args$data <- "mtcars" -args$data <- rlang::syms(args$data) -args$id <- paste0("fit_", args$x1, "_", args$x2) -# print(args) # Requires `args` to be a tibble # nolint -plan <- map_plan(args, my_model_fit) -plan -# Consider `trace = TRUE` to include the columns in `args` -# in your plan. -plan <- map_plan(args, my_model_fit, trace = TRUE) -# print(plan) # If you have tibble installed # nolint -# And of course, you can execute the plan and -# inspect your results. -cache <- storr::storr_environment() -make(plan, verbose = FALSE, cache = cache) -readd(fit_cyl_disp, cache = cache) -}) -} -} \seealso{ \code{\link[=drake_plan]{drake_plan()}} } diff --git a/man/parallelism_choices.Rd b/man/parallelism_choices.Rd index 433a60b19..844a20f2b 100644 --- a/man/parallelism_choices.Rd +++ b/man/parallelism_choices.Rd @@ -15,7 +15,4 @@ character vector \description{ 2019-01-03 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/plan_analyses.Rd b/man/plan_analyses.Rd index 8b257fc64..04b2fbb1d 100644 --- a/man/plan_analyses.Rd +++ b/man/plan_analyses.Rd @@ -31,7 +31,4 @@ for details. \details{ 2019-01-13 } -\examples{ -# Deprecated -} \keyword{internal} diff --git a/man/plan_summaries.Rd b/man/plan_summaries.Rd index 88a019240..d0c30cb20 100644 --- a/man/plan_summaries.Rd +++ b/man/plan_summaries.Rd @@ -38,7 +38,4 @@ for details. \details{ 2019-01-13 } -\examples{ -# Deprecated -} \keyword{internal} diff --git a/man/process_import.Rd b/man/process_import.Rd index 645855116..a6e388c4d 100644 --- a/man/process_import.Rd +++ b/man/process_import.Rd @@ -14,7 +14,4 @@ process_import(import, config) \description{ only used inside process_imports(). Not a user-side function. } -\examples{ -# Not a user-side function. -} \keyword{internal} diff --git a/man/prune_drake_graph.Rd b/man/prune_drake_graph.Rd index e4efeb593..9f08c725d 100644 --- a/man/prune_drake_graph.Rd +++ b/man/prune_drake_graph.Rd @@ -19,7 +19,4 @@ An \code{igraph} object \description{ 2019-01-08 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/r_recipe_wildcard.Rd b/man/r_recipe_wildcard.Rd index ef994ddc8..d7ff247cf 100644 --- a/man/r_recipe_wildcard.Rd +++ b/man/r_recipe_wildcard.Rd @@ -12,7 +12,4 @@ The R recipe wildcard. \description{ 2019-01-02 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/read_drake_config.Rd b/man/read_drake_config.Rd index 1c88fa00a..6372e66ef 100644 --- a/man/read_drake_config.Rd +++ b/man/read_drake_config.Rd @@ -33,7 +33,4 @@ improves speed. \details{ 2019-01-06 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/read_drake_graph.Rd b/man/read_drake_graph.Rd index b6cb40b8b..1de76babe 100644 --- a/man/read_drake_graph.Rd +++ b/man/read_drake_graph.Rd @@ -31,7 +31,4 @@ improves speed. \details{ 2019-01-06 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/read_drake_plan.Rd b/man/read_drake_plan.Rd index 308ba437f..af4817aa9 100644 --- a/man/read_drake_plan.Rd +++ b/man/read_drake_plan.Rd @@ -31,7 +31,4 @@ improves speed. \details{ 2019-01-06 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/read_drake_seed.Rd b/man/read_drake_seed.Rd index 2c7e6d736..dc9233175 100644 --- a/man/read_drake_seed.Rd +++ b/man/read_drake_seed.Rd @@ -35,6 +35,8 @@ this one central seed. That way, reproducibility is protected, even under randomness. } \examples{ +\dontrun{ +isolate_example("contain side effects", { cache <- storr::storr_environment() # Just for the examples. my_plan <- drake_plan( target1 = sqrt(1234), @@ -67,4 +69,6 @@ cache <- storr::storr_environment() # Just for the examples. make(my_plan, cache = cache, seed = 1234) read_drake_seed(cache = cache) readd(target2, cache = cache) +}) +} } diff --git a/man/reduce_by.Rd b/man/reduce_by.Rd index e6d69a2fb..44ea55a36 100644 --- a/man/reduce_by.Rd +++ b/man/reduce_by.Rd @@ -61,38 +61,6 @@ Perform several calls to \code{reduce_plan()} based on groupings from columns in the plan, and then row-bind the new targets to the plan. } -\examples{ -\dontrun{ -suppressWarnings({ -plan <- drake_plan( - data = get_data(), - informal_look = inspect_data(data, mu = mu__), - bayes_model = bayesian_model_fit(data, prior_mu = mu__) -) -plan <- evaluate_plan(plan, rules = list(mu__ = 1:2), trace = TRUE) -plan -reduce_by(plan, mu___from, begin = "list(", end = ")", op = ", ") -reduce_by(plan, mu__) -reduce_by(plan, mu__, append = TRUE) -reduce_by(plan, mu__, append = FALSE) -reduce_by(plan) # Reduce all the targets. -reduce_by(plan, append = FALSE) -reduce_by(plan, pairwise = FALSE) -# You can filter out the informal_look_* targets beforehand -# if you only want the bayes_model_* ones to be reduced. -# The advantage here is that if you also need `append = TRUE`, -# only the bayes_model_* targets will be reduced, but -# the informal_look_* targets will still be included -# in the output. -reduce_by( - plan, - mu___from, - append = TRUE, - filter = mu___from == "bayes_model" -) -}) -} -} \seealso{ \code{\link[=drake_plan]{drake_plan()}} } diff --git a/man/reduce_plan.Rd b/man/reduce_plan.Rd index 93b4a09ea..45d1ffefa 100644 --- a/man/reduce_plan.Rd +++ b/man/reduce_plan.Rd @@ -47,38 +47,6 @@ Creates a new workflow plan data frame with the commands to do a reduction (i.e. to repeatedly apply a binary operator to pairs of targets to produce one target). } -\examples{ -\dontrun{ -suppressWarnings({ -# Workflow plan for datasets: -x_plan <- evaluate_plan( - drake_plan(x = VALUE), - wildcard = "VALUE", - values = 1:8 -) -x_plan -# Create a new target from the sum of the others. -reduce_plan(x_plan, target = "x_sum", pairwise = FALSE, append = FALSE) -# Optionally include the original rows with `append = TRUE`. -reduce_plan(x_plan, target = "x_sum", pairwise = FALSE, append = TRUE) -# For memory efficiency and parallel computing, -# reduce pairwise: -reduce_plan(x_plan, target = "x_sum", pairwise = TRUE, append = FALSE) -# Optionally define your own function and use it as the -# binary operator in the reduction. -x_plan <- evaluate_plan( - drake_plan(x = VALUE), - wildcard = "VALUE", - values = 1:9 -) -x_plan -reduce_plan( - x_plan, target = "x_sum", pairwise = TRUE, - begin = "fun(", op = ", ", end = ")" -) -}) -} -} \seealso{ \code{\link[=drake_plan]{drake_plan()}} } diff --git a/man/render_static_drake_graph.Rd b/man/render_static_drake_graph.Rd index c46b3c95e..e343e2e80 100644 --- a/man/render_static_drake_graph.Rd +++ b/man/render_static_drake_graph.Rd @@ -25,7 +25,4 @@ Use \code{\link[=render_drake_ggraph]{render_drake_ggraph()}} instead. \details{ Deprecated on 2018-07-25. } -\examples{ -# See render_drake_ggraph() -} \keyword{internal} diff --git a/man/shell_file.Rd b/man/shell_file.Rd index d500ba466..59b70e03d 100644 --- a/man/shell_file.Rd +++ b/man/shell_file.Rd @@ -17,7 +17,4 @@ logical \description{ 2019-01-03 } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/short_hash.Rd b/man/short_hash.Rd index a9e64219f..a1d10bbb7 100644 --- a/man/short_hash.Rd +++ b/man/short_hash.Rd @@ -23,7 +23,4 @@ A character vector naming a hash algorithm. \description{ Deprecated on 2018-12-12. } -\examples{ -# deprecated -} \keyword{internal} diff --git a/man/show_source.Rd b/man/show_source.Rd index 0ba129951..cf408ccf5 100644 --- a/man/show_source.Rd +++ b/man/show_source.Rd @@ -21,9 +21,13 @@ Show the command that produced a target or indicate that the object or file was imported. } \examples{ +\dontrun{ +isolate_example("contain side effects", { plan <- drake_plan(x = sample.int(15)) cache <- storr::storr_environment() # custom in-memory cache make(plan, cache = cache) config <- drake_config(plan, cache = cache) show_source(x, config) +}) +} } diff --git a/man/static_drake_graph.Rd b/man/static_drake_graph.Rd index c294276c7..56ec85f09 100644 --- a/man/static_drake_graph.Rd +++ b/man/static_drake_graph.Rd @@ -96,7 +96,4 @@ Use \code{\link[=drake_ggraph]{drake_ggraph()}} instead. \details{ Deprecated on 2018-07-25. } -\examples{ -# See drake_ggraph() -} \keyword{internal} diff --git a/man/triggers.Rd b/man/triggers.Rd index 5cf188d60..53e59dd5d 100644 --- a/man/triggers.Rd +++ b/man/triggers.Rd @@ -17,7 +17,4 @@ is outdated or up to date. \details{ Deprecated on 2018-07-22. } -\examples{ -# Deprecated. See the trigger() function instead (singular). -} \keyword{internal} diff --git a/man/use_drake.Rd b/man/use_drake.Rd index 7fe9bd3bd..69e75d4f3 100644 --- a/man/use_drake.Rd +++ b/man/use_drake.Rd @@ -35,5 +35,7 @@ and download examples with \code{\link[=drake_example]{drake_example()}} } } \examples{ +\dontrun{ # use_drake(open = FALSE) # nolint } +}