From 3112ee74ea8dcc5a52a36040f29ff74e36141ee4 Mon Sep 17 00:00:00 2001 From: wlandau Date: Wed, 4 Jul 2018 08:51:36 -0400 Subject: [PATCH] Start on #440 --- NAMESPACE | 1 - R/config.R | 22 ++++-- R/dependencies.R | 9 +-- R/deprecate.R | 27 ++++---- R/drake_graph_info.R | 2 +- R/graph.R | 102 ++++----------------------- R/meta.R | 51 +++++++++++++- R/vis_drake_graph.R | 2 +- _pkgdown.yml | 1 - man/build_drake_graph.Rd | 108 ----------------------------- man/build_graph.Rd | 17 ++--- man/drake_config.Rd | 9 ++- man/drake_graph_info.Rd | 2 +- man/drake_meta.Rd | 3 +- man/make.Rd | 3 +- man/prune_drake_graph.Rd | 5 +- man/vis_drake_graph.Rd | 2 +- tests/testthat/test-dependencies.R | 36 +++++----- tests/testthat/test-deprecate.R | 1 + tests/testthat/test-graph.R | 6 +- 20 files changed, 144 insertions(+), 265 deletions(-) delete mode 100644 man/build_drake_graph.Rd diff --git a/NAMESPACE b/NAMESPACE index 388c638ba..1fe29337d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,7 +9,6 @@ export(available_hash_algos) export(backend) export(bind_plans) export(build_clustermq) -export(build_drake_graph) export(build_graph) export(build_times) export(built) diff --git a/R/config.R b/R/config.R index c49cbd9bd..c11daf6a4 100644 --- a/R/config.R +++ b/R/config.R @@ -216,8 +216,7 @@ #' #' @param graph An `igraph` object from the previous `make()`. #' Supplying a pre-built graph could save time. -#' The graph is constructed by [build_drake_graph()]. -#' You can also get one from \code{\link{config}(my_plan)$graph}. +#' You can also get one from \code{\link{drake_config}(my_plan)$graph}. #' Overrides `skip_imports`. #' #' @param trigger Name of the trigger to apply to all targets. @@ -356,6 +355,10 @@ #' (`make(parallelism = x)`, where `x` could be `"mclapply"`, #' `"parLapply"`, or `"future_lapply"`). #' +#' @param meta an environment used as a hash table for quickly +#' looking up target/import-level metadata. You can supply a `meta` +#' from a previous `config` with this argument. +#' #' @examples #' \dontrun{ #' test_with_dir("Quarantine side effects.", { @@ -416,7 +419,8 @@ drake_config <- function( pruning_strategy = c("speed", "memory"), makefile_path = "Makefile", console_log_file = NULL, - ensure_workers = TRUE + ensure_workers = TRUE, + meta = NULL ){ force(envir) unlink(console_log_file) @@ -454,10 +458,14 @@ drake_config <- function( ) seed <- choose_seed(supplied = seed, cache = cache) trigger <- match.arg(arg = trigger, choices = triggers()) + if (is.null(meta)){ + meta <- initialize_meta_lookup( + plan = plan, targets = targets, envir = envir, + verbose = verbose, jobs = jobs, console_log_file = console_log_file + ) + } if (is.null(graph)){ - graph <- build_drake_graph(plan = plan, targets = targets, - envir = envir, verbose = verbose, jobs = jobs, - sanitize_plan = FALSE, console_log_file = console_log_file) + graph <- build_igraph(targets = targets, meta = meta, jobs = jobs) } else { graph <- prune_drake_graph(graph = graph, to = targets, jobs = jobs) } @@ -471,7 +479,7 @@ drake_config <- function( jobs_imports = jobs["imports"], jobs_targets = jobs["targets"], verbose = verbose, hook = hook, prepend = prepend, prework = prework, command = command, - args = args, recipe_command = recipe_command, graph = graph, + args = args, recipe_command = recipe_command, graph = graph, meta = meta, short_hash_algo = cache$get("short_hash_algo", namespace = "config"), long_hash_algo = cache$get("long_hash_algo", namespace = "config"), seed = seed, trigger = trigger, diff --git a/R/dependencies.R b/R/dependencies.R index a3904982b..097d20497 100644 --- a/R/dependencies.R +++ b/R/dependencies.R @@ -200,11 +200,12 @@ tracked <- function( verbose = drake::default_verbose() ){ force(envir) - graph <- build_drake_graph( + config <- drake_config( plan = plan, targets = targets, envir = envir, - jobs = jobs, verbose = verbose + verbose = verbose, jobs = jobs, + cache = storr::storr_environment() ) - V(graph)$name + V(config$graph)$name } dependencies <- function(targets, config, reverse = FALSE){ @@ -231,7 +232,7 @@ import_dependencies <- function(expr){ # Imported functions can't have file_out() deps # nolint # or target dependencies from knitr code chunks. # However, file_in()s are totally fine. # nolint - deps$file_out <- deps$loadd <- deps$readd <- deps$strings <- NULL + deps$file_out <- deps$strings <- NULL deps } diff --git a/R/deprecate.R b/R/deprecate.R index 8fde06123..8d2c173a0 100644 --- a/R/deprecate.R +++ b/R/deprecate.R @@ -104,17 +104,18 @@ backend <- function(...){ } #' @title Deprecated function `build_graph` -#' @description Use [build_drake_graph()] instead. +#' @description Use `drake_config()$graph` instead. #' @details Deprecated on 2017-11-12. #' @export #' @keywords internal -#' @seealso [build_drake_graph()] -#' @return The same return value as [build_drake_graph()]. -#' @param plan Same as for [build_drake_graph()]. -#' @param targets Same as for [build_drake_graph()]. -#' @param envir Same as for [build_drake_graph()]. -#' @param verbose Same as for [build_drake_graph()]. -#' @param jobs Same as for [build_drake_graph()]. +#' @aliases build_drake_graph +#' @seealso [drake_config()] +#' @return The same return value as `drake_config()$graph`. +#' @param plan Same as for `drake_config()$graph`. +#' @param targets Same as for `drake_config()$graph`. +#' @param envir Same as for `drake_config()$graph`. +#' @param verbose Same as for `drake_config()$graph`. +#' @param jobs Same as for `drake_config()$graph`. #' @examples #' # See ?as_drake_filename for examples. build_graph <- function( @@ -130,15 +131,17 @@ build_graph <- function( msg = paste( "drake::build_graph() is deprecated", "due to possible name conflicts.", - "Use build_drake_graph() instead." + "Use `drake_config()$graph` instead." ) ) - build_drake_graph( + drake_config( plan = plan, targets = targets, envir = envir, verbose = verbose, - jobs = jobs - ) + jobs = jobs, cache = storr::storr_environment() + )$graph } +build_drake_graph <- build_graph + #' @title Deprecated function `check` #' @description Use [check_plan()] instead. #' @details Deprecated on 2017-11-12. diff --git a/R/drake_graph_info.R b/R/drake_graph_info.R index 4f96d2634..fbcfd7079 100644 --- a/R/drake_graph_info.R +++ b/R/drake_graph_info.R @@ -7,7 +7,7 @@ #' one for edges, and one for #' the legend nodes. The list also contains the #' default title of the graph. -#' @seealso [vis_drake_graph()], [build_drake_graph()] +#' @seealso [vis_drake_graph()] #' @param config a [drake_config()] configuration list. #' You can get one as a return value from [make()] as well. #' diff --git a/R/graph.R b/R/graph.R index 37bc1314a..0e2dcdff2 100644 --- a/R/graph.R +++ b/R/graph.R @@ -1,106 +1,29 @@ -#' @title 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. -#' @seealso [vis_drake_graph()] -#' @export -#' @return An igraph object representing -#' the workflow plan dependency network. -#' @inheritParams drake_config -#' @param sanitize_plan logical, whether to sanitize the workflow plan first. -#' @examples -#' \dontrun{ -#' 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" -#' }) -#' } -build_drake_graph <- function( - 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 -){ - force(envir) - if (sanitize_plan){ - plan <- sanitize_plan(plan) - } - targets <- sanitize_targets(plan, targets) - imports <- as.list(envir) - unload_conflicts( - imports = names(imports), - targets = plan$target, - envir = envir, - verbose = verbose - ) - import_names <- setdiff(names(imports), targets) - imports <- imports[import_names] - config <- list(verbose = verbose, console_log_file = console_log_file) - console_many_targets( - targets = names(imports), - pattern = "connect", - type = "import", - config = config - ) - imports_edges <- lightly_parallelize( - X = seq_along(imports), - FUN = function(i){ - imports_edges(name = import_names[[i]], value = imports[[i]]) - }, - jobs = jobs - ) - console_many_targets( - targets = plan$target, - pattern = "connect", - type = "target", - config = config - ) - commands_edges <- lightly_parallelize( - X = seq_len(nrow(plan)), - FUN = function(i){ - commands_edges(target = plan$target[i], command = plan$command[i]) - }, - jobs = jobs - ) - c(imports_edges, commands_edges) %>% +build_igraph <- function(targets, meta, jobs){ + as.list(meta) %>% + purrr::map(.f = target_meta_to_edges) %>% do.call(what = rbind) %>% igraph::graph_from_data_frame() %>% prune_drake_graph(to = targets, jobs = jobs) %>% igraph::simplify(remove.multiple = TRUE, remove.loops = TRUE) } -commands_edges <- function(target, command){ - deps <- command_dependencies(command) - code_deps_to_edges(target = target, deps = deps) -} - -imports_edges <- function(name, value){ - deps <- import_dependencies(value) - code_deps_to_edges(target = name, deps = deps) -} - -code_deps_to_edges <- function(target, deps){ - inputs <- clean_dependency_list(deps[setdiff(names(deps), "file_out")]) +target_meta_to_edges <- function(deps){ + name <- deps$name + deps <- deps[ + c("globals", "namespaced", "file_in", "knitr_in", "loadd", "readd")] + inputs <- clean_dependency_list(deps) edges <- NULL if (length(inputs)){ - data.frame(from = inputs, to = target, stringsAsFactors = FALSE) + data.frame(from = inputs, to = name, stringsAsFactors = FALSE) } else { # Loops will be removed. - data.frame(from = target, to = target, stringsAsFactors = FALSE) + data.frame(from = name, to = name, stringsAsFactors = FALSE) } } #' @title Prune the dependency network of your project. #' @export -#' @seealso [build_drake_graph()], [config()], +#' @seealso [config()], #' [make()] #' @description `igraph` objects are used #' internally to represent the dependency network of your workflow. @@ -120,8 +43,7 @@ code_deps_to_edges <- function(target, deps){ #' test_with_dir("Quarantine side effects.", { #' load_mtcars_example() # Get the code with drake_example("mtcars"). #' # Build the igraph object representing the workflow dependency network. -#' # You could also use drake_config(my_plan)$graph -#' graph <- build_drake_graph(my_plan) +#' graph <- drake_config(my_plan)$graph #' # The default plotting is not the greatest, #' # but you will get the idea. #' plot(graph) diff --git a/R/meta.R b/R/meta.R index 47c5ea867..e9796fe3a 100644 --- a/R/meta.R +++ b/R/meta.R @@ -1,4 +1,53 @@ -#' @title Compute the initial pre-build metadata of a target or import. +initialize_meta_lookup <- function( + plan, targets, envir, verbose, jobs, console_log_file +){ + imports <- as.list(envir) + unload_conflicts( + imports = names(imports), + targets = plan$target, + envir = envir, + verbose = verbose + ) + import_names <- setdiff(names(imports), targets) + imports <- imports[import_names] + config <- list(verbose = verbose, console_log_file = console_log_file) + console_many_targets( + targets = names(imports), + pattern = "connect", + type = "import", + config = config + ) + import_deps <- lightly_parallelize( + X = names(imports), + FUN = function(name){ + out <- import_dependencies(imports[[name]]) + out$name <- name + out + }, + jobs = jobs + ) + names(import_deps) <- names(imports) + console_many_targets( + targets = plan$target, + pattern = "connect", + type = "target", + config = config + ) + command_deps <- lightly_parallelize( + X = seq_len(nrow(plan)), + FUN = function(i){ + out <- command_dependencies(plan$command[i]) + out$name <- plan$target[i] + out + }, + jobs = jobs + ) + names(command_deps) <- plan$target + list2env(c(import_deps, command_deps), parent = emptyenv(), hash = TRUE) +} + +#' @title Compute the initial pre-build trigger-related +#' metadata of a target or import. #' @description The metadata helps determine if the #' target is up to date or outdated. The metadata of imports #' is used to compute the metadata of targets. diff --git a/R/vis_drake_graph.R b/R/vis_drake_graph.R index d18dc96bd..738e01b7e 100644 --- a/R/vis_drake_graph.R +++ b/R/vis_drake_graph.R @@ -5,7 +5,7 @@ #' [drake_graph_info()] and [render_drake_graph()]. #' @export #' @aliases drake_graph -#' @seealso [build_drake_graph()] +#' @seealso [drake_graph_info()], [render_drake_graph()] #' @return A visNetwork graph. #' @inheritParams drake_graph_info #' @inheritParams render_drake_graph diff --git a/_pkgdown.yml b/_pkgdown.yml index dcf0cbeb4..673046fba 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -57,7 +57,6 @@ reference: - '`plan_summaries`' - title: Network graphs and visualization contents: - - '`build_drake_graph`' - '`drake_palette`' - '`drake_graph_info`' - '`legend_nodes`' diff --git a/man/build_drake_graph.Rd b/man/build_drake_graph.Rd deleted file mode 100644 index 1a8da33da..000000000 --- a/man/build_drake_graph.Rd +++ /dev/null @@ -1,108 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/graph.R -\name{build_drake_graph} -\alias{build_drake_graph} -\title{Create the \code{igraph} dependency network of your project.} -\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{ -\item{plan}{workflow plan data frame. -A workflow plan data frame is a data frame -with a \code{target} column and a \code{command} column. -(See the details in the \code{\link[=drake_plan]{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 \code{\link[=drake_plan]{drake_plan()}} to generate workflow plan -data frames easily, and see functions \code{\link[=plan_analyses]{plan_analyses()}}, -\code{\link[=plan_summaries]{plan_summaries()}}, \code{\link[=evaluate_plan]{evaluate_plan()}}, -\code{\link[=expand_plan]{expand_plan()}}, and \code{\link[=gather_plan]{gather_plan()}} for -easy ways to generate large workflow plan data frames.} - -\item{targets}{character vector, names of targets to build. -Dependencies are built too. Together, the \code{plan} and -\code{targets} comprise the workflow network -(i.e. the \code{graph} argument). -Changing either will change the network.} - -\item{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 \code{envir} is made, -so you don't need to worry about your workspace being modified -by \code{make}. The deep copy inherits from the global environment. -Wherever necessary, objects and functions are imported -from \code{envir} and the global environment and -then reproducibly tracked as dependencies.} - -\item{verbose}{logical or numeric, control printing to the console. -Use \code{pkgconfig} to set the default value of \code{verbose} -for your R session: -for example, \code{pkgconfig::set_config("drake::verbose" = 2)}. -\describe{ -\item{0 or \code{FALSE}:}{print nothing.} -\item{1 or \code{TRUE}:}{print only targets to build.} -\item{2:}{in addition, print checks and cache info.} -\item{3:}{in addition, print any potentially missing items.} -\item{4:}{in addition, print imports. Full verbosity.} -}} - -\item{jobs}{number of parallel processes or jobs to run. -See \code{\link[=max_useful_jobs]{max_useful_jobs()}} or \code{\link[=vis_drake_graph]{vis_drake_graph()}} -to help figure out what the number of jobs should be. -Windows users should not set \code{jobs > 1} if -\code{parallelism} is \code{"mclapply"} because -\code{\link[=mclapply]{mclapply()}} is based on forking. Windows users -who use \code{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 -\code{make(..., jobs = c(imports = 2, targets = 4))}. - -If \code{parallelism} is \code{"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 \code{jobs} -argument to \code{\link[=make]{make()}}. To use at most 2 jobs for imports and at -most 4 jobs for targets, run -\code{make(..., parallelism = "Makefile", jobs = c(imports = 2, targets = 4))} or -\code{make(..., parallelism = "Makefile", jobs = 2, args = "--jobs=4")}.} - -\item{sanitize_plan}{logical, whether to sanitize the workflow plan first.} - -\item{console_log_file}{character scalar or \code{NULL}. -If \code{NULL}, console output will be printed -to the R console using \code{message()}. -Otherwise, \code{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. -} -\description{ -This function returns an igraph object representing how -the targets in your workflow plan data frame -depend on each other. -(\code{help(package = "igraph")}). To plot the graph, call -to \code{\link[=plot.igraph]{plot.igraph()}} on your graph, or just use -\code{\link[=vis_drake_graph]{vis_drake_graph()}} from the start. -} -\examples{ -\dontrun{ -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" -}) -} -} -\seealso{ -\code{\link[=vis_drake_graph]{vis_drake_graph()}} -} diff --git a/man/build_graph.Rd b/man/build_graph.Rd index 519d55cbf..a4e0b3860 100644 --- a/man/build_graph.Rd +++ b/man/build_graph.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/deprecate.R \name{build_graph} \alias{build_graph} +\alias{build_drake_graph} \title{Deprecated function \code{build_graph}} \usage{ build_graph(plan = read_drake_plan(), @@ -9,21 +10,21 @@ build_graph(plan = read_drake_plan(), verbose = 1, jobs = 1) } \arguments{ -\item{plan}{Same as for \code{\link[=build_drake_graph]{build_drake_graph()}}.} +\item{plan}{Same as for \code{drake_config()$graph}.} -\item{targets}{Same as for \code{\link[=build_drake_graph]{build_drake_graph()}}.} +\item{targets}{Same as for \code{drake_config()$graph}.} -\item{envir}{Same as for \code{\link[=build_drake_graph]{build_drake_graph()}}.} +\item{envir}{Same as for \code{drake_config()$graph}.} -\item{verbose}{Same as for \code{\link[=build_drake_graph]{build_drake_graph()}}.} +\item{verbose}{Same as for \code{drake_config()$graph}.} -\item{jobs}{Same as for \code{\link[=build_drake_graph]{build_drake_graph()}}.} +\item{jobs}{Same as for \code{drake_config()$graph}.} } \value{ -The same return value as \code{\link[=build_drake_graph]{build_drake_graph()}}. +The same return value as \code{drake_config()$graph}. } \description{ -Use \code{\link[=build_drake_graph]{build_drake_graph()}} instead. +Use \code{drake_config()$graph} instead. } \details{ Deprecated on 2017-11-12. @@ -32,6 +33,6 @@ Deprecated on 2017-11-12. # See ?as_drake_filename for examples. } \seealso{ -\code{\link[=build_drake_graph]{build_drake_graph()}} +\code{\link[=drake_config]{drake_config()}} } \keyword{internal} diff --git a/man/drake_config.Rd b/man/drake_config.Rd index 3b6b3b201..948a0ad45 100644 --- a/man/drake_config.Rd +++ b/man/drake_config.Rd @@ -22,7 +22,7 @@ drake_config(plan = read_drake_plan(), seed = NULL, caching = c("worker", "master"), keep_going = FALSE, session = NULL, imports_only = NULL, pruning_strategy = c("speed", "memory"), makefile_path = "Makefile", console_log_file = NULL, - ensure_workers = TRUE) + ensure_workers = TRUE, meta = NULL) } \arguments{ \item{plan}{workflow plan data frame. @@ -218,8 +218,7 @@ will no longer work if you do that.} \item{graph}{An \code{igraph} object from the previous \code{make()}. Supplying a pre-built graph could save time. -The graph is constructed by \code{\link[=build_drake_graph]{build_drake_graph()}}. -You can also get one from \code{\link{config}(my_plan)$graph}. +You can also get one from \code{\link{drake_config}(my_plan)$graph}. Overrides \code{skip_imports}.} \item{trigger}{Name of the trigger to apply to all targets. @@ -366,6 +365,10 @@ for \code{make(parallelism = "future_lapply", jobs = n)} This argument only applies to parallel computing with persistent workers (\code{make(parallelism = x)}, where \code{x} could be \code{"mclapply"}, \code{"parLapply"}, or \code{"future_lapply"}).} + +\item{meta}{an environment used as a hash table for quickly +looking up target/import-level metadata. You can supply a \code{meta} +from a previous \code{config} with this argument.} } \value{ The master internal configuration list of a project. diff --git a/man/drake_graph_info.Rd b/man/drake_graph_info.Rd index e0df60518..28f74f1e5 100644 --- a/man/drake_graph_info.Rd +++ b/man/drake_graph_info.Rd @@ -110,5 +110,5 @@ visNetwork(nodes = raw_graph$nodes, edges = raw_graph$edges) \%>\% } } \seealso{ -\code{\link[=vis_drake_graph]{vis_drake_graph()}}, \code{\link[=build_drake_graph]{build_drake_graph()}} +\code{\link[=vis_drake_graph]{vis_drake_graph()}} } diff --git a/man/drake_meta.Rd b/man/drake_meta.Rd index 9c1f48baa..aaa2cfb7e 100644 --- a/man/drake_meta.Rd +++ b/man/drake_meta.Rd @@ -2,7 +2,8 @@ % Please edit documentation in R/meta.R \name{drake_meta} \alias{drake_meta} -\title{Compute the initial pre-build metadata of a target or import.} +\title{Compute the initial pre-build trigger-related +metadata of a target or import.} \usage{ drake_meta(target, config = drake::read_drake_config()) } diff --git a/man/make.Rd b/man/make.Rd index 7fa31ab7c..373c568bf 100644 --- a/man/make.Rd +++ b/man/make.Rd @@ -225,8 +225,7 @@ is always invisibly returned.} \item{graph}{An \code{igraph} object from the previous \code{make()}. Supplying a pre-built graph could save time. -The graph is constructed by \code{\link[=build_drake_graph]{build_drake_graph()}}. -You can also get one from \code{\link{config}(my_plan)$graph}. +You can also get one from \code{\link{drake_config}(my_plan)$graph}. Overrides \code{skip_imports}.} \item{trigger}{Name of the trigger to apply to all targets. diff --git a/man/prune_drake_graph.Rd b/man/prune_drake_graph.Rd index 69dab12f2..813c69d13 100644 --- a/man/prune_drake_graph.Rd +++ b/man/prune_drake_graph.Rd @@ -34,8 +34,7 @@ remove the vertices after \code{to} from the graph. test_with_dir("Quarantine side effects.", { load_mtcars_example() # Get the code with drake_example("mtcars"). # Build the igraph object representing the workflow dependency network. -# You could also use drake_config(my_plan)$graph -graph <- build_drake_graph(my_plan) +graph <- drake_config(my_plan)$graph # The default plotting is not the greatest, # but you will get the idea. plot(graph) @@ -47,6 +46,6 @@ plot(pruned) } } \seealso{ -\code{\link[=build_drake_graph]{build_drake_graph()}}, \code{\link[=config]{config()}}, +\code{\link[=config]{config()}}, \code{\link[=make]{make()}} } diff --git a/man/vis_drake_graph.Rd b/man/vis_drake_graph.Rd index 3e7918d31..f6f388c61 100644 --- a/man/vis_drake_graph.Rd +++ b/man/vis_drake_graph.Rd @@ -138,5 +138,5 @@ vis_drake_graph( } } \seealso{ -\code{\link[=build_drake_graph]{build_drake_graph()}} +\code{\link[=drake_graph_info]{drake_graph_info()}}, \code{\link[=render_drake_graph]{render_drake_graph()}} } diff --git a/tests/testthat/test-dependencies.R b/tests/testthat/test-dependencies.R index e0d38c99b..45d5be3f3 100644 --- a/tests/testthat/test-dependencies.R +++ b/tests/testthat/test-dependencies.R @@ -35,23 +35,27 @@ test_with_dir("file_out() and knitr_in(): commands vs imports", { mustWork = TRUE ) file.copy(from = path, to = getwd(), overwrite = TRUE) - x <- commands_edges("\"y\"", cmd) - y <- imports_edges("f", f) - expect_equal( - sort(x$from), - sort( - c("coef_regression2_small", "large", - "\"report.Rmd\"", "small", "\"x\"" - ) - ) - ) - expect_equal(x$to, rep("\"y\"", 5)) - expect_equal( - sort(y$from), - sort(c("\"report.Rmd\"", "\"x\"")) + x <- command_dependencies(cmd) + x0 <- list( + file_in = "\"x\"", file_out = "\"y\"", loadd = "large", + readd = c("small", "coef_regression2_small"), + knitr_in = "\"report.Rmd\"") + expect_equal(length(x), length(x0)) + for (i in names(x)){ + expect_equal(sort(x[[i]]), sort(x0[[i]]) ) + } + y <- import_dependencies(f) + y0 <- list( + file_in = "\"x\"", + knitr_in = "\"report.Rmd\"", + loadd = "large", + readd = c("small", "coef_regression2_small") ) - expect_equal(y$to, rep("f", 2)) - expect_equal(sort(deps_code(f)), sort(c("\"report.Rmd\"", "\"x\""))) + expect_equal(length(y), length(y0)) + for (i in names(y)){ + expect_equal(sort(y[[i]]), sort(y0[[i]]) ) + } + expect_equal(sort(deps_code(f)), sort(unname(unlist(y)))) expect_equal( sort(deps_code(cmd)), sort( diff --git a/tests/testthat/test-deprecate.R b/tests/testthat/test-deprecate.R index 951e1f0ac..92c65d562 100644 --- a/tests/testthat/test-deprecate.R +++ b/tests/testthat/test-deprecate.R @@ -104,6 +104,7 @@ test_with_dir("deprecated graphing functions", { skip_on_cran() # CRAN gets whitelist tests only (check time limits). pl <- drake_plan(a = 1) expect_warning(build_graph(pl)) + expect_warning(build_drake_graph(pl)) con <- drake_config(plan = pl) expect_warning(out <- plot_graph(config = con)) df <- drake_graph_info(config = con) diff --git a/tests/testthat/test-graph.R b/tests/testthat/test-graph.R index 506546135..caef272fd 100644 --- a/tests/testthat/test-graph.R +++ b/tests/testthat/test-graph.R @@ -74,8 +74,6 @@ test_with_dir("Supplied graph disagrees with the workflow plan", { test_with_dir("graph functions work", { skip_on_cran() # CRAN gets whitelist tests only (check time limits). config <- dbug() - expect_equal( - class(build_drake_graph(config$plan, verbose = FALSE)), "igraph") pdf(NULL) tmp <- vis_drake_graph(config) dev.off() @@ -89,8 +87,8 @@ test_with_dir("graph functions work", { test_with_dir("Supplied graph is pruned.", { skip_on_cran() # CRAN gets whitelist tests only (check time limits). load_mtcars_example() - graph <- build_drake_graph(my_plan) - con <- drake_config(my_plan, targets = c("small", "large"), graph = graph) + con0 <- drake_config(my_plan) + con <- drake_config(my_plan, targets = c("small", "large"), graph = con0$graph) vertices <- V(con$graph)$name include <- c("small", "simulate", "data.frame", "sample.int", "large") exclude <- setdiff(my_plan$target, include)