From 4e8e34b31e29732dbe5258931df62959a843cbbc Mon Sep 17 00:00:00 2001 From: wlandau Date: Thu, 2 Jan 2025 15:56:42 -0500 Subject: [PATCH] tar_outdated() sensible defaults --- DESCRIPTION | 2 +- NEWS.md | 5 ++++- R/class_outdated.R | 2 +- R/class_sitrep.R | 18 ++++++++++++------ R/tar_config_get.R | 6 ++++-- R/tar_config_set.R | 21 +++++++++++++++++---- R/tar_mermaid.R | 3 ++- R/tar_network.R | 3 ++- R/tar_outdated.R | 22 ++++++++++++++++++---- R/tar_sitrep.R | 11 ++++++++--- R/tar_visnetwork.R | 3 ++- man/tar_config_set.Rd | 10 +++++++++- man/tar_mermaid.Rd | 13 +++++++------ man/tar_network.Rd | 13 +++++++------ man/tar_outdated.Rd | 13 +++++++------ man/tar_sitrep.Rd | 16 +++++++++++----- man/tar_visnetwork.Rd | 13 +++++++------ tests/testthat/test-tar_config_set.R | 23 +++++++++++++++++++---- 18 files changed, 138 insertions(+), 59 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 59d01dd9e..20129f5f3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -12,7 +12,7 @@ Description: Pipeline tools coordinate the pieces of computationally The methodology in this package borrows from GNU 'Make' (2015, ISBN:978-9881443519) and 'drake' (2018, ). -Version: 1.9.1.9004 +Version: 1.9.1.9005 License: MIT + file LICENSE URL: https://docs.ropensci.org/targets/, https://github.com/ropensci/targets BugReports: https://github.com/ropensci/targets/issues diff --git a/NEWS.md b/NEWS.md index d011439ea..fe8fda34e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,12 @@ -# targets 1.9.1.9004 +# targets 1.9.1.9005 * Use a more lookup-efficient data structure for `tar_runtime$file_info` (#1398). * Fall back on vector aggregation without names (#1401, @guglicap). * Reduce overhead in `tar_outdated()` by at least 33% (#1408). * Speed up representation of file sizes in metadata (#1408). This may slow down the next call to `tar_make()` in existing pipelines, but the new file size format will update in the metadata during that call, and then `tar_make()` should be faster after that. +* Add a new `"forecast_interactive"` reporter to `tar_outdated()` to choose `"forecast"` for interactive sessions and `"silent"` for non-interactive ones. +* Add a new `seconds_reporter_outdated` argument to `tar_config_set()` with a default of 0.5 to control the time interval of the reporter of `tar_outdated()` and other passive algorithm functions. +* Remove target descriptions from the default labels of graph visualizations. # targets 1.9.1 diff --git a/R/class_outdated.R b/R/class_outdated.R index 84f21b07f..3bed109dc 100644 --- a/R/class_outdated.R +++ b/R/class_outdated.R @@ -7,7 +7,7 @@ outdated_init <- function( reporter = "silent", seconds_meta_append = 0, seconds_meta_upload = 15, - seconds_reporter = 0 + seconds_reporter = 0.5 ) { outdated_new( pipeline = pipeline, diff --git a/R/class_sitrep.R b/R/class_sitrep.R index f044a89a6..b444e6d96 100644 --- a/R/class_sitrep.R +++ b/R/class_sitrep.R @@ -4,7 +4,8 @@ sitrep_init <- function( names = NULL, shortcut = FALSE, queue = "sequential", - reporter = "silent" + reporter = "silent", + seconds_reporter = 0.5 ) { sitrep_new( pipeline = pipeline, @@ -12,7 +13,8 @@ sitrep_init <- function( names = names, shortcut = shortcut, queue = queue, - reporter = reporter + reporter = reporter, + seconds_reporter = seconds_reporter ) } @@ -22,7 +24,8 @@ sitrep_new <- function( names = NULL, shortcut = shortcut, queue = NULL, - reporter = NULL + reporter = NULL, + seconds_reporter = NULL ) { sitrep_class$new( pipeline = pipeline, @@ -30,7 +33,8 @@ sitrep_new <- function( names = names, shortcut = shortcut, queue = queue, - reporter = reporter + reporter = reporter, + seconds_reporter = seconds_reporter ) } @@ -49,7 +53,8 @@ sitrep_class <- R6::R6Class( names = NULL, shortcut = NULL, queue = NULL, - reporter = NULL + reporter = NULL, + seconds_reporter = NULL ) { super$initialize( pipeline = pipeline, @@ -57,7 +62,8 @@ sitrep_class <- R6::R6Class( names = names, shortcut = shortcut, queue = queue, - reporter = reporter + reporter = reporter, + seconds_reporter = seconds_reporter ) self$sitrep <- new.env(parent = emptyenv()) }, diff --git a/R/tar_config_get.R b/R/tar_config_get.R index 183a19a44..2f7f6d2dc 100644 --- a/R/tar_config_get.R +++ b/R/tar_config_get.R @@ -88,15 +88,16 @@ tar_config_get_project <- function(name, yaml) { inherits = yaml$inherits, as_job = yaml$as_job %|||% FALSE, garbage_collection = yaml$garbage_collection, - label = yaml$label %|||% "description", + label = yaml$label %|||% character(0L), label_width = yaml$label_width %|||% 30L, level_separation = yaml$level_separation, reporter_make = yaml$reporter_make %|||% "verbose", - reporter_outdated = yaml$reporter_outdated %|||% "silent", + reporter_outdated = yaml$reporter_outdated %|||% "forecast_interactive", script = yaml$script %|||% path_script_default(), seconds_meta_append = yaml$seconds_meta_append %|||% 0, seconds_meta_upload = yaml$seconds_meta_upload %|||% 15, seconds_reporter = yaml$seconds_reporter %|||% 0, + seconds_reporter_outdated = yaml$seconds_reporter_outdated %|||% 0.25, seconds_interval = yaml$seconds_interval, shortcut = yaml$shortcut %|||% FALSE, store = yaml$store %|||% path_store_default(), @@ -120,6 +121,7 @@ tar_config_get_convert <- function(name, value) { seconds_meta_append = as.numeric(value), seconds_meta_upload = as.numeric(value), seconds_reporter = as.numeric(value), + seconds_reporter_outdated = as.numeric(value), seconds_interval = if_any(is.null(value), NULL, as.numeric(value)), shortcut = as.logical(value), store = as.character(value), diff --git a/R/tar_config_set.R b/R/tar_config_set.R index fb4032147..0a7af02a8 100644 --- a/R/tar_config_set.R +++ b/R/tar_config_set.R @@ -97,7 +97,13 @@ #' @param seconds_reporter Argument of [tar_make()], [tar_make_clustermq()], #' and [tar_make_future()]. Positive numeric of length 1 with the minimum #' number of seconds between times when the reporter prints progress -#' messages to the R console. +#' messages to the R console (for the aforementioned +#' [tar_make()]-like functions only). +#' @param seconds_reporter_outdated Argument of [tar_outdated()] +#' and other related functions that do not run the pipeline. +#' Positive numeric of length 1 with the minimum +#' number of seconds between times when the reporter prints progress +#' messages to the R console for [tar_outdated()]. #' @param shortcut logical of length 1, default `shortcut` argument #' to [tar_make()] and related functions. #' If the argument `NULL`, the setting is not modified. @@ -177,6 +183,7 @@ tar_config_set <- function( seconds_meta_append = NULL, seconds_meta_upload = NULL, seconds_reporter = NULL, + seconds_reporter_outdated = NULL, seconds_interval = NULL, store = NULL, shortcut = NULL, @@ -203,6 +210,7 @@ tar_config_set <- function( tar_config_assert_seconds_meta_append(seconds_meta_append) tar_config_assert_seconds_meta_upload(seconds_meta_upload) tar_config_assert_seconds_reporter(seconds_reporter) + tar_config_assert_seconds_reporter_outdated(seconds_reporter_outdated) tar_config_assert_seconds_interval(seconds_interval) tar_config_assert_shortcut(shortcut) tar_config_assert_store(store) @@ -226,8 +234,10 @@ tar_config_set <- function( yaml[[project]]$seconds_meta_append yaml[[project]]$seconds_meta_upload <- seconds_meta_upload %|||% yaml[[project]]$seconds_meta_upload - yaml[[project]]$seconds_reporter <- seconds_reporter %|||% - yaml[[project]]$seconds_reporter + yaml[[project]][["seconds_reporter"]] <- seconds_reporter %|||% + yaml[[project]][["seconds_reporter"]] + yaml[[project]]$seconds_reporter_outdated <- seconds_reporter_outdated %|||% + yaml[[project]]$seconds_reporter_outdated yaml[[project]]$seconds_interval <- seconds_interval %|||% yaml[[project]]$seconds_interval yaml[[project]]$shortcut <- shortcut %|||% yaml[[project]]$shortcut @@ -372,6 +382,9 @@ tar_config_assert_seconds_reporter <- function(seconds_reporter) { tar_assert_ge(seconds_reporter, 0) } +tar_config_assert_seconds_reporter_outdated <- + tar_config_assert_seconds_reporter + tar_config_assert_shortcut <- function(shortcut) { if (is.null(shortcut)) { return() @@ -418,7 +431,7 @@ tar_reporters_make <- function() { } tar_reporters_outdated <- function() { - c("forecast", "silent") + c("forecast_interactive", "forecast", "silent") } tar_config_read_yaml <- function(config) { diff --git a/R/tar_mermaid.R b/R/tar_mermaid.R index 8a1a84adc..6296a7f2a 100644 --- a/R/tar_mermaid.R +++ b/R/tar_mermaid.R @@ -52,7 +52,7 @@ tar_mermaid <- function( legend = TRUE, color = TRUE, reporter = targets::tar_config_get("reporter_outdated"), - seconds_reporter = targets::tar_config_get("seconds_reporter"), + seconds_reporter = targets::tar_config_get("seconds_reporter_outdated"), callr_function = callr::r, callr_arguments = targets::tar_callr_args_default(callr_function), envir = parent.frame(), @@ -72,6 +72,7 @@ tar_mermaid <- function( tar_assert_scalar(legend) tar_assert_scalar(color) tar_config_assert_reporter_outdated(reporter) + reporter <- tar_outdated_reporter(reporter) tar_assert_callr_function(callr_function) tar_assert_list(callr_arguments, "callr_arguments mut be a list.") tar_assert_dbl(seconds_reporter) diff --git a/R/tar_network.R b/R/tar_network.R index 025500548..981a35bfe 100644 --- a/R/tar_network.R +++ b/R/tar_network.R @@ -82,7 +82,7 @@ tar_network <- function( exclude = NULL, outdated = TRUE, reporter = targets::tar_config_get("reporter_outdated"), - seconds_reporter = targets::tar_config_get("seconds_reporter"), + seconds_reporter = targets::tar_config_get("seconds_reporter_outdated"), callr_function = callr::r, callr_arguments = targets::tar_callr_args_default(callr_function, reporter), envir = parent.frame(), @@ -92,6 +92,7 @@ tar_network <- function( force(envir) tar_assert_lgl(targets_only) tar_config_assert_reporter_outdated(reporter) + reporter <- tar_outdated_reporter(reporter) tar_assert_callr_function(callr_function) tar_assert_list(callr_arguments) tar_assert_dbl(seconds_reporter) diff --git a/R/tar_outdated.R b/R/tar_outdated.R index 5c17c35b0..48a96f2a0 100644 --- a/R/tar_outdated.R +++ b/R/tar_outdated.R @@ -37,9 +37,12 @@ #' created by running the target script file (default: `_targets.R`). #' @param reporter Character of length 1, name of the reporter to user. #' Controls how messages are printed as targets are checked. Choices: -#' * `"silent"`: print nothing. -#' * `"forecast"`: print running totals of the checked and outdated -#' targets found so far. +#' * `"forecast_interactive"` (default): use the forecast reporter if the +#' session is interactive (see [base::interactive()]), +#' otherwise use the silent reporter. +#' * `"silent"`: print nothing. +#' * `"forecast"`: print running totals of the checked and outdated +#' targets found so far. #' @inheritParams tar_validate #' @examples #' if (identical(Sys.getenv("TAR_EXAMPLES"), "true")) { # for CRAN @@ -64,7 +67,7 @@ tar_outdated <- function( branches = FALSE, targets_only = TRUE, reporter = targets::tar_config_get("reporter_outdated"), - seconds_reporter = targets::tar_config_get("seconds_reporter"), + seconds_reporter = targets::tar_config_get("seconds_reporter_outdated"), seconds_interval = targets::tar_config_get("seconds_interval"), callr_function = callr::r, callr_arguments = targets::tar_callr_args_default(callr_function, reporter), @@ -78,6 +81,7 @@ tar_outdated <- function( tar_assert_lgl(shortcut) tar_assert_lgl(branches) tar_assert_flag(reporter, tar_reporters_outdated()) + reporter <- tar_outdated_reporter(reporter) tar_assert_dbl(seconds_reporter) tar_assert_scalar(seconds_reporter) tar_assert_none_na(seconds_reporter) @@ -159,3 +163,13 @@ tar_outdated_globals <- function(pipeline, meta) { different[is.na(different)] <- TRUE comparison$name[different] } + +tar_outdated_reporter <- function(reporter) { + if (identical(reporter, "forecast_interactive")) { + reporter <- if_any( + interactive(), + "forecast", + "silent" + ) + } +} diff --git a/R/tar_sitrep.R b/R/tar_sitrep.R index 943d1f57e..07e389387 100644 --- a/R/tar_sitrep.R +++ b/R/tar_sitrep.R @@ -97,6 +97,7 @@ tar_sitrep <- function( fields = NULL, shortcut = targets::tar_config_get("shortcut"), reporter = targets::tar_config_get("reporter_outdated"), + seconds_reporter = targets::tar_config_get("seconds_reporter_outdated"), callr_function = callr::r, callr_arguments = targets::tar_callr_args_default(callr_function, reporter), envir = parent.frame(), @@ -110,6 +111,7 @@ tar_sitrep <- function( tar_assert_scalar(shortcut) tar_assert_lgl(shortcut) tar_assert_flag(reporter, tar_reporters_outdated()) + reporter <- tar_outdated_reporter(reporter) tar_assert_callr_function(callr_function) tar_assert_list(callr_arguments) tar_message_meta(store = store) @@ -118,7 +120,8 @@ tar_sitrep <- function( names_quosure = rlang::enquo(names), shortcut = shortcut, fields_quosure = rlang::enquo(fields), - reporter = reporter + reporter = reporter, + seconds_reporter = seconds_reporter ) callr_outer( targets_function = tar_sitrep_inner, @@ -138,7 +141,8 @@ tar_sitrep_inner <- function( names_quosure, shortcut, fields_quosure, - reporter + reporter, + seconds_reporter ) { names_all <- pipeline_get_names(pipeline) names <- tar_tidyselect_eval(names_quosure, names_all) @@ -148,7 +152,8 @@ tar_sitrep_inner <- function( names = names, shortcut = shortcut, queue = "sequential", - reporter = reporter + reporter = reporter, + seconds_reporter = seconds_reporter ) sitrep$run() out <- tibble::as_tibble(data.table::rbindlist(as.list(sitrep$sitrep))) diff --git a/R/tar_visnetwork.R b/R/tar_visnetwork.R index 79423b5fd..f12d6e2b1 100644 --- a/R/tar_visnetwork.R +++ b/R/tar_visnetwork.R @@ -47,7 +47,7 @@ tar_visnetwork <- function( zoom_speed = 1, physics = FALSE, reporter = targets::tar_config_get("reporter_outdated"), - seconds_reporter = targets::tar_config_get("seconds_reporter"), + seconds_reporter = targets::tar_config_get("seconds_reporter_outdated"), callr_function = callr::r, callr_arguments = targets::tar_callr_args_default(callr_function), envir = parent.frame(), @@ -76,6 +76,7 @@ tar_visnetwork <- function( tar_assert_lgl(physics) tar_assert_scalar(physics) tar_config_assert_reporter_outdated(reporter) + reporter <- tar_outdated_reporter(reporter) tar_assert_dbl(seconds_reporter) tar_assert_scalar(seconds_reporter) tar_assert_none_na(seconds_reporter) diff --git a/man/tar_config_set.Rd b/man/tar_config_set.Rd index 2e73546a0..894200c9f 100644 --- a/man/tar_config_set.Rd +++ b/man/tar_config_set.Rd @@ -17,6 +17,7 @@ tar_config_set( seconds_meta_append = NULL, seconds_meta_upload = NULL, seconds_reporter = NULL, + seconds_reporter_outdated = NULL, seconds_interval = NULL, store = NULL, shortcut = NULL, @@ -101,7 +102,14 @@ regardless of \code{seconds_meta_upload}.} \item{seconds_reporter}{Argument of \code{\link[=tar_make]{tar_make()}}, \code{\link[=tar_make_clustermq]{tar_make_clustermq()}}, and \code{\link[=tar_make_future]{tar_make_future()}}. Positive numeric of length 1 with the minimum number of seconds between times when the reporter prints progress -messages to the R console.} +messages to the R console (for the aforementioned +\code{\link[=tar_make]{tar_make()}}-like functions only).} + +\item{seconds_reporter_outdated}{Argument of \code{\link[=tar_outdated]{tar_outdated()}} +and other related functions that do not run the pipeline. +Positive numeric of length 1 with the minimum +number of seconds between times when the reporter prints progress +messages to the R console for \code{\link[=tar_outdated]{tar_outdated()}}.} \item{seconds_interval}{Deprecated on 2023-08-24 (version 1.2.2.9001). Use \code{seconds_meta_append}, \code{seconds_meta_upload}, diff --git a/man/tar_mermaid.Rd b/man/tar_mermaid.Rd index ae30437d1..738be093b 100644 --- a/man/tar_mermaid.Rd +++ b/man/tar_mermaid.Rd @@ -16,7 +16,7 @@ tar_mermaid( legend = TRUE, color = TRUE, reporter = targets::tar_config_get("reporter_outdated"), - seconds_reporter = targets::tar_config_get("seconds_reporter"), + seconds_reporter = targets::tar_config_get("seconds_reporter_outdated"), callr_function = callr::r, callr_arguments = targets::tar_callr_args_default(callr_function), envir = parent.frame(), @@ -88,11 +88,12 @@ by status.} \item{reporter}{Character of length 1, name of the reporter to user. Controls how messages are printed as targets are checked. Choices: -\itemize{ -\item \code{"silent"}: print nothing. -\item \code{"forecast"}: print running totals of the checked and outdated -targets found so far. -}} +* \code{"forecast_interactive"} (default): use the forecast reporter if the +session is interactive (see \code{\link[base:interactive]{base::interactive()}}), +otherwise use the silent reporter. +* \code{"silent"}: print nothing. +* \code{"forecast"}: print running totals of the checked and outdated +targets found so far.} \item{seconds_reporter}{Positive numeric of length 1 with the minimum number of seconds between times when the reporter prints progress diff --git a/man/tar_network.Rd b/man/tar_network.Rd index fff9ffcc4..c3cc0283f 100644 --- a/man/tar_network.Rd +++ b/man/tar_network.Rd @@ -12,7 +12,7 @@ tar_network( exclude = NULL, outdated = TRUE, reporter = targets::tar_config_get("reporter_outdated"), - seconds_reporter = targets::tar_config_get("seconds_reporter"), + seconds_reporter = targets::tar_config_get("seconds_reporter_outdated"), callr_function = callr::r, callr_arguments = targets::tar_callr_args_default(callr_function, reporter), envir = parent.frame(), @@ -68,11 +68,12 @@ if you only want to see dependency relationships and pipeline progress.} \item{reporter}{Character of length 1, name of the reporter to user. Controls how messages are printed as targets are checked. Choices: -\itemize{ -\item \code{"silent"}: print nothing. -\item \code{"forecast"}: print running totals of the checked and outdated -targets found so far. -}} +* \code{"forecast_interactive"} (default): use the forecast reporter if the +session is interactive (see \code{\link[base:interactive]{base::interactive()}}), +otherwise use the silent reporter. +* \code{"silent"}: print nothing. +* \code{"forecast"}: print running totals of the checked and outdated +targets found so far.} \item{seconds_reporter}{Positive numeric of length 1 with the minimum number of seconds between times when the reporter prints progress diff --git a/man/tar_outdated.Rd b/man/tar_outdated.Rd index dfa783542..35eb0b69b 100644 --- a/man/tar_outdated.Rd +++ b/man/tar_outdated.Rd @@ -10,7 +10,7 @@ tar_outdated( branches = FALSE, targets_only = TRUE, reporter = targets::tar_config_get("reporter_outdated"), - seconds_reporter = targets::tar_config_get("seconds_reporter"), + seconds_reporter = targets::tar_config_get("seconds_reporter_outdated"), seconds_interval = targets::tar_config_get("seconds_interval"), callr_function = callr::r, callr_arguments = targets::tar_callr_args_default(callr_function, reporter), @@ -50,11 +50,12 @@ created by running the target script file (default: \verb{_targets.R}).} \item{reporter}{Character of length 1, name of the reporter to user. Controls how messages are printed as targets are checked. Choices: -\itemize{ -\item \code{"silent"}: print nothing. -\item \code{"forecast"}: print running totals of the checked and outdated -targets found so far. -}} +* \code{"forecast_interactive"} (default): use the forecast reporter if the +session is interactive (see \code{\link[base:interactive]{base::interactive()}}), +otherwise use the silent reporter. +* \code{"silent"}: print nothing. +* \code{"forecast"}: print running totals of the checked and outdated +targets found so far.} \item{seconds_reporter}{Positive numeric of length 1 with the minimum number of seconds between times when the reporter prints progress diff --git a/man/tar_sitrep.Rd b/man/tar_sitrep.Rd index 001e413ef..a498a6f2d 100644 --- a/man/tar_sitrep.Rd +++ b/man/tar_sitrep.Rd @@ -9,6 +9,7 @@ tar_sitrep( fields = NULL, shortcut = targets::tar_config_get("shortcut"), reporter = targets::tar_config_get("reporter_outdated"), + seconds_reporter = targets::tar_config_get("seconds_reporter_outdated"), callr_function = callr::r, callr_arguments = targets::tar_callr_args_default(callr_function, reporter), envir = parent.frame(), @@ -83,11 +84,16 @@ Use with caution. \code{shortcut = TRUE} only works if you set \code{names}.} \item{reporter}{Character of length 1, name of the reporter to user. Controls how messages are printed as targets are checked. Choices: -\itemize{ -\item \code{"silent"}: print nothing. -\item \code{"forecast"}: print running totals of the checked and outdated -targets found so far. -}} +* \code{"forecast_interactive"} (default): use the forecast reporter if the +session is interactive (see \code{\link[base:interactive]{base::interactive()}}), +otherwise use the silent reporter. +* \code{"silent"}: print nothing. +* \code{"forecast"}: print running totals of the checked and outdated +targets found so far.} + +\item{seconds_reporter}{Positive numeric of length 1 with the minimum +number of seconds between times when the reporter prints progress +messages to the R console.} \item{callr_function}{A function from \code{callr} to start a fresh clean R process to do the work. Set to \code{NULL} to run in the current session diff --git a/man/tar_visnetwork.Rd b/man/tar_visnetwork.Rd index bb6eda25f..cf8b64ca6 100644 --- a/man/tar_visnetwork.Rd +++ b/man/tar_visnetwork.Rd @@ -19,7 +19,7 @@ tar_visnetwork( zoom_speed = 1, physics = FALSE, reporter = targets::tar_config_get("reporter_outdated"), - seconds_reporter = targets::tar_config_get("seconds_reporter"), + seconds_reporter = targets::tar_config_get("seconds_reporter_outdated"), callr_function = callr::r, callr_arguments = targets::tar_callr_args_default(callr_function), envir = parent.frame(), @@ -109,11 +109,12 @@ physics in the graph, e.g. edge elasticity.} \item{reporter}{Character of length 1, name of the reporter to user. Controls how messages are printed as targets are checked. Choices: -\itemize{ -\item \code{"silent"}: print nothing. -\item \code{"forecast"}: print running totals of the checked and outdated -targets found so far. -}} +* \code{"forecast_interactive"} (default): use the forecast reporter if the +session is interactive (see \code{\link[base:interactive]{base::interactive()}}), +otherwise use the silent reporter. +* \code{"silent"}: print nothing. +* \code{"forecast"}: print running totals of the checked and outdated +targets found so far.} \item{seconds_reporter}{Positive numeric of length 1 with the minimum number of seconds between times when the reporter prints progress diff --git a/tests/testthat/test-tar_config_set.R b/tests/testthat/test-tar_config_set.R index 03a586004..4f6522f7a 100644 --- a/tests/testthat/test-tar_config_set.R +++ b/tests/testthat/test-tar_config_set.R @@ -49,7 +49,7 @@ tar_test("tar_config_set() garbage_collection", { tar_test("tar_config_set() label", { skip_cran() expect_false(file.exists("_targets.yaml")) - expect_equal(tar_config_get("label"), "description") + expect_equal(tar_config_get("label"), character(0L)) tar_config_set(label = c("size", "time")) expect_equal(tar_config_get("label"), c("size", "time")) expect_true(file.exists("_targets.yaml")) @@ -62,7 +62,7 @@ tar_test("tar_config_set() label", { tar_config_set(label = character(0L)) expect_equal(tar_config_get("label"), character(0L)) unlink("_targets.yaml") - expect_equal(tar_config_get("label"), "description") + expect_equal(tar_config_get("label"), character(0L)) }) tar_test("tar_config_set() label_width", { @@ -117,7 +117,7 @@ tar_test("tar_config_set() reporter_make", { tar_test("tar_config_set() reporter_outdated", { skip_cran() expect_false(file.exists("_targets.yaml")) - expect_equal(tar_config_get("reporter_outdated"), "silent") + expect_equal(tar_config_get("reporter_outdated"), "forecast_interactive") tar_config_set(reporter_outdated = "forecast") expect_equal(tar_config_get("reporter_outdated"), "forecast") expect_true(file.exists("_targets.yaml")) @@ -126,7 +126,7 @@ tar_test("tar_config_set() reporter_outdated", { expect_equal(tar_config_get("reporter_outdated"), "forecast") expect_true(file.exists("_targets.yaml")) unlink("_targets.yaml") - expect_equal(tar_config_get("reporter_outdated"), "silent") + expect_equal(tar_config_get("reporter_outdated"), "forecast_interactive") }) tar_test("tar_config_set() shortcut", { @@ -222,6 +222,21 @@ tar_test("tar_config_set() with seconds_reporter", { expect_equal(tar_config_get("seconds_reporter"), 0) }) +tar_test("tar_config_set() with seconds_reporter_outdated", { + skip_cran() + expect_false(file.exists("_targets.yaml")) + expect_equal(tar_config_get("seconds_reporter_outdated"), 0.25) + path <- tempfile() + tar_config_set(seconds_reporter_outdated = 10) + expect_equal(tar_config_get("seconds_reporter_outdated"), 10) + expect_true(file.exists("_targets.yaml")) + tar_config_set() + expect_equal(tar_config_get("seconds_reporter_outdated"), 10) + expect_true(file.exists("_targets.yaml")) + unlink("_targets.yaml") + expect_equal(tar_config_get("seconds_reporter_outdated"), 0.25) +}) + tar_test("tar_config_set() with seconds_interval", { skip_cran() expect_false(file.exists("_targets.yaml"))