diff --git a/NEWS.md b/NEWS.md index 51546affa..b9da000d0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # Version 7.9.0.9000 +## New features + +- Add a new `format` argument to `make()`, an optional custom storage format for targets without an explicit `target(format = ...)` in the plan (#1124). + ## Enhancements - Smoothly deprecate the `config` argument in all user-side functions (#1118, @vkehayas). Users can now supply the plan and other `make()` arguments directly, without bothering with `drake_config()`. Now, you only need to call `drake_config()` in the `_drake.R` file for `r_make()` and friends. Old code with `config` objects should still work. Affected functions: diff --git a/R/drake_config.R b/R/drake_config.R index c4ada13bc..4209af511 100644 --- a/R/drake_config.R +++ b/R/drake_config.R @@ -467,6 +467,11 @@ #' Mac users may notice a 20% speedup in `make()` #' with `build_times = FALSE`. #' +#' @param format Character, an optional custom storage format for targets +#' without an explicit `target(format = ...)` in the plan. Details +#' about formats: +#' # nolint +#' #' @examples #' \dontrun{ #' isolate_example("quarantine side effects", { @@ -539,7 +544,8 @@ drake_config <- function( recoverable = TRUE, curl_handles = list(), max_expand = NULL, - log_build_times = TRUE + log_build_times = TRUE, + format = NULL ) { logger <- logger(verbose = verbose, file = console_log_file) logger$minor("begin drake_config()") @@ -661,7 +667,8 @@ drake_config <- function( ht_is_dynamic = ht_is_dynamic, ht_is_subtarget = ht_is_subtarget, # Gets replaced in make() max_expand = max_expand, - log_build_times = log_build_times + log_build_times = log_build_times, + format = format ) class(out) <- c("drake_config", "drake") config_checks(out) diff --git a/R/local_build.R b/R/local_build.R index 9055f10ed..c7f2dd464 100644 --- a/R/local_build.R +++ b/R/local_build.R @@ -328,18 +328,14 @@ conclude_build <- function(build, config) { meta <- build$meta assert_output_files(target = target, meta = meta, config = config) handle_build_exceptions(target = target, meta = meta, config = config) - value <- assign_format( - target = target, - value = value, - format = config$spec[[target]]$format, - config = config - ) + value <- assign_format(target = target, value = value, config = config) store_outputs(target = target, value = value, meta = meta, config = config) assign_to_envir(target = target, value = value, config = config) invisible(value) } -assign_format <- function(target, value, format, config) { +assign_format <- function(target, value, config) { + format <- config$spec[[target]]$format %||NA% config$format drop_format <- is.null(format) || is.na(format) || is.null(value) || diff --git a/R/make.R b/R/make.R index a2a682db7..d004b7630 100644 --- a/R/make.R +++ b/R/make.R @@ -162,7 +162,8 @@ make <- function( recoverable = TRUE, curl_handles = list(), max_expand = NULL, - log_build_times = TRUE + log_build_times = TRUE, + format = NULL ) { force(envir) deprecate_arg(config, "config") @@ -219,7 +220,8 @@ make <- function( recoverable = recoverable, curl_handles = curl_handles, max_expand = max_expand, - log_build_times = log_build_times + log_build_times = log_build_times, + format = format ) make_impl(config) } diff --git a/man/drake_config.Rd b/man/drake_config.Rd index f0934ba2b..d8c7afcd4 100644 --- a/man/drake_config.Rd +++ b/man/drake_config.Rd @@ -58,7 +58,8 @@ drake_config( recoverable = TRUE, curl_handles = list(), max_expand = NULL, - log_build_times = TRUE + log_build_times = TRUE, + format = NULL ) } \arguments{ @@ -525,6 +526,11 @@ is an argument of \code{drake_plan()} and \code{transform_plan()}.} \item{log_build_times}{Logical, whether to record build_times for targets. Mac users may notice a 20\% speedup in \code{make()} with \code{build_times = FALSE}.} + +\item{format}{Character, an optional custom storage format for targets +without an explicit \code{target(format = ...)} in the plan. Details +about formats: +\url{https://books.ropensci.org/drake/plans.html#special-data-formats-for-targets} # nolint} } \value{ A configured \code{drake} workflow. diff --git a/man/make.Rd b/man/make.Rd index 0852d856b..8e1863368 100644 --- a/man/make.Rd +++ b/man/make.Rd @@ -59,7 +59,8 @@ make( recoverable = TRUE, curl_handles = list(), max_expand = NULL, - log_build_times = TRUE + log_build_times = TRUE, + format = NULL ) } \arguments{ @@ -528,6 +529,11 @@ is an argument of \code{drake_plan()} and \code{transform_plan()}.} \item{log_build_times}{Logical, whether to record build_times for targets. Mac users may notice a 20\% speedup in \code{make()} with \code{build_times = FALSE}.} + +\item{format}{Character, an optional custom storage format for targets +without an explicit \code{target(format = ...)} in the plan. Details +about formats: +\url{https://books.ropensci.org/drake/plans.html#special-data-formats-for-targets} # nolint} } \value{ nothing