Skip to content

Commit

Permalink
Start #1124. Need tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Dec 28, 2019
1 parent 7a26233 commit 7511ef2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 13 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
11 changes: 9 additions & 2 deletions R/drake_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#' <https://books.ropensci.org/drake/plans.html#special-data-formats-for-targets> # nolint
#'
#' @examples
#' \dontrun{
#' isolate_example("quarantine side effects", {
Expand Down Expand Up @@ -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()")
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 3 additions & 7 deletions R/local_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
6 changes: 4 additions & 2 deletions R/make.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 7 additions & 1 deletion man/drake_config.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion man/make.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7511ef2

Please sign in to comment.