diff --git a/DESCRIPTION b/DESCRIPTION index 361d1737d..5f3a69dfc 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.3.0.9002 +Version: 1.3.0.9003 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 3367d8187..6d7f82c16 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# targets 1.3.0.9001 (development) +# targets 1.3.0.9003 (development) * Add `tar_config_projects()` and `tar_config_yaml()` (#1153, @psychelzh). * Apply error modes to `builder_wait_correct_hash()` in `target_conclude.tar_builder()` (#1154, @gadenbuie). @@ -6,6 +6,7 @@ * Allow `tar_meta_upload()` and `tar_meta_download()` to avoid errors if one or more metadata files do not exist. Add a new argument `strict` to control error behavior. * Add new arguments `meta`, `progress`, `process`, and `crew` to control individual metadata files in `tar_meta_upload()`, `tar_meta_download()`, `tar_meta_sync()`, and `tar_meta_delete()`. * Avoid newly deprecated arguments and functions in `crew` 0.5.0.9003 (https://github.com/wlnadau/crew/issues/131). +* Allow `tar_read()` etc. inside a pipeline whenever it uses a different data store (#1158, @MilesMcBain). # targets 1.3.0 diff --git a/R/tar_built.R b/R/tar_built.R index d0af9e05c..5bdd271cc 100644 --- a/R/tar_built.R +++ b/R/tar_built.R @@ -26,7 +26,7 @@ tar_built <- function( names = NULL, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_built") + tar_assert_allow_meta("tar_built", store) progress <- progress_init(path_store = store) progress <- tibble::as_tibble(progress$database$read_condensed_data()) names_quosure <- rlang::enquo(names) diff --git a/R/tar_canceled.R b/R/tar_canceled.R index ac3d32a1a..0466ed2cf 100644 --- a/R/tar_canceled.R +++ b/R/tar_canceled.R @@ -26,7 +26,7 @@ tar_canceled <- function( names = NULL, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_canceled") + tar_assert_allow_meta("tar_canceled", store) progress <- progress_init(path_store = store) progress <- tibble::as_tibble(progress$database$read_condensed_data()) names_quosure <- rlang::enquo(names) diff --git a/R/tar_config_set.R b/R/tar_config_set.R index 411d6a046..0dc8365e7 100644 --- a/R/tar_config_set.R +++ b/R/tar_config_set.R @@ -180,7 +180,7 @@ tar_config_set <- function( ) { # TODO: remove single-project format, which was deprecated on # 2021-09-03 (version 0.7.0.9001). - tar_assert_allow_meta("tar_config_set") + tar_assert_allow_meta("tar_config_set", store) tar_assert_chr(config) tar_assert_scalar(config) tar_assert_chr(project) diff --git a/R/tar_config_unset.R b/R/tar_config_unset.R index 1c158a2f5..223e6c4d8 100644 --- a/R/tar_config_unset.R +++ b/R/tar_config_unset.R @@ -29,7 +29,7 @@ tar_config_unset <- function( config = Sys.getenv("TAR_CONFIG", "_targets.yaml"), project = Sys.getenv("TAR_PROJECT", "main") ) { - tar_assert_allow_meta("tar_config_unset") + tar_assert_allow_meta("tar_config_unset", store) tar_assert_chr(config) tar_assert_scalar(config) tar_assert_chr(project) diff --git a/R/tar_crew.R b/R/tar_crew.R index 348c44191..2ab75aa4a 100644 --- a/R/tar_crew.R +++ b/R/tar_crew.R @@ -29,7 +29,7 @@ #' }) #' } tar_crew <- function(store = targets::tar_config_get("store")) { - tar_assert_allow_meta("tar_crew") + tar_assert_allow_meta("tar_crew", store) tar_assert_scalar(store) tar_assert_chr(store) tar_assert_nzchar(store) diff --git a/R/tar_deduplicate.R b/R/tar_deduplicate.R index 80ffdf5f2..7020ad53c 100644 --- a/R/tar_deduplicate.R +++ b/R/tar_deduplicate.R @@ -20,7 +20,7 @@ tar_deduplicate <- function( progress = TRUE, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_deduplicate") + tar_assert_allow_meta("tar_deduplicate", store) tar_warn_deprecate( "tar_deduplicate() is deprecated in version 0.3.0 (2020-03-06). ", "The tar_make*() functions do enough deduplication now automatically." diff --git a/R/tar_delete.R b/R/tar_delete.R index 694ffaf6c..765886389 100644 --- a/R/tar_delete.R +++ b/R/tar_delete.R @@ -52,7 +52,7 @@ tar_delete <- function( cloud = TRUE, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_delete") + tar_assert_allow_meta("tar_delete", store) tar_assert_store(store = store) tar_assert_path(path_meta(store)) meta <- meta_init(path_store = store)$database$read_condensed_data() diff --git a/R/tar_destroy.R b/R/tar_destroy.R index 9c514fdd5..887905c25 100644 --- a/R/tar_destroy.R +++ b/R/tar_destroy.R @@ -92,7 +92,7 @@ tar_destroy <- function( script = targets::tar_config_get("script"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_destroy") + tar_assert_allow_meta("tar_destroy", store) if (!file.exists(store)) { return(invisible()) } diff --git a/R/tar_edit.R b/R/tar_edit.R index de040700a..892ca4c4d 100644 --- a/R/tar_edit.R +++ b/R/tar_edit.R @@ -11,7 +11,6 @@ tar_edit <- function(script = targets::tar_config_get("script")) { # Covered in tests/interactive/test-tar_edit.R # nolint # nocov start - tar_assert_allow_meta("tar_edit") tar_assert_package("usethis") usethis::edit_file(path = script, open = TRUE) # nocov end diff --git a/R/tar_errored.R b/R/tar_errored.R index 1ee324cfc..80c849663 100644 --- a/R/tar_errored.R +++ b/R/tar_errored.R @@ -27,7 +27,7 @@ tar_errored <- function( names = NULL, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_errored") + tar_assert_allow_meta("tar_errored", store) progress <- progress_init(path_store = store) progress <- tibble::as_tibble(progress$database$read_condensed_data()) names_quosure <- rlang::enquo(names) diff --git a/R/tar_exist_meta.R b/R/tar_exist_meta.R index e25fe16e9..5adc43db2 100644 --- a/R/tar_exist_meta.R +++ b/R/tar_exist_meta.R @@ -10,6 +10,6 @@ #' @examples #' tar_exist_meta() tar_exist_meta <- function(store = targets::tar_config_get("store")) { - tar_assert_allow_meta("tar_exist_meta") + tar_assert_allow_meta("tar_exist_meta", store) file.exists(path_meta(path_store = store)) } diff --git a/R/tar_exist_objects.R b/R/tar_exist_objects.R index 761564e41..55191c899 100644 --- a/R/tar_exist_objects.R +++ b/R/tar_exist_objects.R @@ -22,7 +22,7 @@ tar_exist_objects <- function( cloud = TRUE, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_exist_objects") + tar_assert_allow_meta("tar_exist_objects", store) tar_assert_chr(names, "names must be a character vector.") meta <- if_any(file.exists(store), tar_meta(store = store), data_frame()) out <- map_lgl( diff --git a/R/tar_exist_process.R b/R/tar_exist_process.R index d9a15d32f..bf7fdb356 100644 --- a/R/tar_exist_process.R +++ b/R/tar_exist_process.R @@ -10,6 +10,6 @@ #' @examples #' tar_exist_process() tar_exist_process <- function(store = targets::tar_config_get("store")) { - tar_assert_allow_meta("tar_exist_process") + tar_assert_allow_meta("tar_exist_process", store) file.exists(path_process(path_store = store)) } diff --git a/R/tar_exist_progress.R b/R/tar_exist_progress.R index 9feaaa045..8efbcea00 100644 --- a/R/tar_exist_progress.R +++ b/R/tar_exist_progress.R @@ -10,6 +10,6 @@ #' @examples #' tar_exist_progress() tar_exist_progress <- function(store = targets::tar_config_get("store")) { - tar_assert_allow_meta("tar_exist_progress") + tar_assert_allow_meta("tar_exist_progress", store) file.exists(path_progress(path_store = store)) } diff --git a/R/tar_exist_script.R b/R/tar_exist_script.R index 0c4fcaeed..aead24f58 100644 --- a/R/tar_exist_script.R +++ b/R/tar_exist_script.R @@ -10,6 +10,5 @@ #' @examples #' tar_exist_script() tar_exist_script <- function(script = targets::tar_config_get("script")) { - tar_assert_allow_meta("tar_exist_script") file.exists(script) } diff --git a/R/tar_glimpse.R b/R/tar_glimpse.R index 1714427fb..d0cd17b8e 100644 --- a/R/tar_glimpse.R +++ b/R/tar_glimpse.R @@ -61,7 +61,7 @@ tar_glimpse <- function( script = targets::tar_config_get("script"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_glimpse") + tar_assert_allow_meta("tar_glimpse", store) force(envir) tar_assert_package("visNetwork") tar_assert_lgl(targets_only) diff --git a/R/tar_invalidate.R b/R/tar_invalidate.R index 0692e9a7c..2e82834e8 100644 --- a/R/tar_invalidate.R +++ b/R/tar_invalidate.R @@ -36,7 +36,7 @@ #' }) #' } tar_invalidate <- function(names, store = targets::tar_config_get("store")) { - tar_assert_allow_meta("tar_invalidate") + tar_assert_allow_meta("tar_invalidate", store) meta <- meta_init(path_store = store) data <- meta$database$read_condensed_data() tar_message_meta(store = store) diff --git a/R/tar_load.R b/R/tar_load.R index 7b1509b3b..2f1ba682a 100644 --- a/R/tar_load.R +++ b/R/tar_load.R @@ -41,7 +41,7 @@ tar_load <- function( envir = parent.frame(), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_load") + tar_assert_allow_meta("tar_load", store) tar_assert_store(store = store) force(meta) force(envir) diff --git a/R/tar_load_everything.R b/R/tar_load_everything.R index dfdfc85b7..0b06a0afc 100644 --- a/R/tar_load_everything.R +++ b/R/tar_load_everything.R @@ -29,7 +29,7 @@ tar_load_everything <- function( envir = parent.frame(), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_load_everything") + tar_assert_allow_meta("tar_load_everything", store) force(envir) tar_load( everything(), diff --git a/R/tar_load_globals.R b/R/tar_load_globals.R index 6f107193d..57e75f556 100644 --- a/R/tar_load_globals.R +++ b/R/tar_load_globals.R @@ -40,7 +40,7 @@ tar_load_globals <- function( envir = parent.frame(), script = targets::tar_config_get("script") ) { - tar_assert_allow_meta("tar_load_globals") + tar_assert_allow_meta("tar_load_globals", store) force(envir) tar_assert_script(script) eval(parse(file = script), envir = envir) diff --git a/R/tar_load_raw.R b/R/tar_load_raw.R index 66bfec7bb..7ef72cb3d 100644 --- a/R/tar_load_raw.R +++ b/R/tar_load_raw.R @@ -49,7 +49,7 @@ tar_load_raw <- function( envir = parent.frame(), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_load_raw") + tar_assert_allow_meta("tar_load_raw", store) tar_assert_store(store = store) force(meta) force(envir) diff --git a/R/tar_make.R b/R/tar_make.R index bc8c57c7e..a2d3b4a60 100644 --- a/R/tar_make.R +++ b/R/tar_make.R @@ -138,7 +138,7 @@ tar_make <- function( use_crew = targets::tar_config_get("use_crew"), terminate_controller = TRUE ) { - tar_assert_allow_meta("tar_make") + tar_assert_allow_meta("tar_make", store) force(envir) tar_assert_scalar(shortcut) tar_assert_lgl(shortcut) diff --git a/R/tar_make_clustermq.R b/R/tar_make_clustermq.R index a6ef01dab..dc4d1c18a 100644 --- a/R/tar_make_clustermq.R +++ b/R/tar_make_clustermq.R @@ -65,7 +65,7 @@ tar_make_clustermq <- function( # Cannot use multicore clustermq backend # due to https://github.com/ropensci/targets/discussions/780 # nocov start - tar_assert_allow_meta("tar_make_clustermq") + tar_assert_allow_meta("tar_make_clustermq", store) force(envir) tar_assert_package("clustermq") tar_assert_scalar(shortcut) diff --git a/R/tar_make_future.R b/R/tar_make_future.R index bb1129939..62ffba8dc 100644 --- a/R/tar_make_future.R +++ b/R/tar_make_future.R @@ -53,7 +53,7 @@ tar_make_future <- function( store = targets::tar_config_get("store"), garbage_collection = targets::tar_config_get("garbage_collection") ) { - tar_assert_allow_meta("tar_make_future") + tar_assert_allow_meta("tar_make_future", store) force(envir) tar_assert_package("future") tar_assert_scalar(shortcut) diff --git a/R/tar_manifest.R b/R/tar_manifest.R index fc63e4a72..7b49cabb5 100644 --- a/R/tar_manifest.R +++ b/R/tar_manifest.R @@ -77,7 +77,7 @@ tar_manifest <- function( envir = parent.frame(), script = targets::tar_config_get("script") ) { - tar_assert_allow_meta("tar_manifest") + tar_assert_allow_meta("tar_manifest", store) force(envir) tar_assert_lgl(drop_missing) tar_assert_scalar(drop_missing) diff --git a/R/tar_meta.R b/R/tar_meta.R index f6f7d4907..75758ccf6 100644 --- a/R/tar_meta.R +++ b/R/tar_meta.R @@ -133,7 +133,7 @@ tar_meta <- function( complete_only = FALSE, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_meta") + tar_assert_allow_meta("tar_meta", store) tar_assert_scalar(store) tar_assert_chr(store) tar_assert_nzchar(store) diff --git a/R/tar_newer.R b/R/tar_newer.R index c1988c806..c394384a2 100644 --- a/R/tar_newer.R +++ b/R/tar_newer.R @@ -48,7 +48,7 @@ tar_newer <- function( inclusive = FALSE, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_newer") + tar_assert_allow_meta("tar_newer", store) tar_assert_scalar(time) tar_assert_inherits(time, "POSIXct") tar_assert_scalar(inclusive) diff --git a/R/tar_objects.R b/R/tar_objects.R index 94c1372e3..10756748a 100644 --- a/R/tar_objects.R +++ b/R/tar_objects.R @@ -30,7 +30,7 @@ tar_objects <- function( cloud = TRUE, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_objects") + tar_assert_allow_meta("tar_objects", store) if (!file.exists(store)) { return(character(0)) } diff --git a/R/tar_older.R b/R/tar_older.R index 6f5f4c05a..5973e179a 100644 --- a/R/tar_older.R +++ b/R/tar_older.R @@ -52,7 +52,7 @@ tar_older <- function( inclusive = FALSE, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_older") + tar_assert_allow_meta("tar_older", store) tar_assert_scalar(time) tar_assert_inherits(time, "POSIXct") tar_assert_scalar(inclusive) diff --git a/R/tar_outdated.R b/R/tar_outdated.R index 3cd906ecb..07bbba817 100644 --- a/R/tar_outdated.R +++ b/R/tar_outdated.R @@ -70,7 +70,7 @@ tar_outdated <- function( script = targets::tar_config_get("script"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_outdated") + tar_assert_allow_meta("tar_outdated", store) force(envir) tar_assert_scalar(shortcut) tar_assert_lgl(shortcut) diff --git a/R/tar_poll.R b/R/tar_poll.R index c0ab26843..f8679c7e8 100644 --- a/R/tar_poll.R +++ b/R/tar_poll.R @@ -29,7 +29,7 @@ tar_poll <- function( fields = c("skipped", "started", "built", "errored", "canceled", "since"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_poll") + tar_assert_allow_meta("tar_poll", store) start <- time_seconds() if (!tar_exist_progress(store = store)) { cli_blue_bullet( diff --git a/R/tar_process.R b/R/tar_process.R index c613fdb3e..ab712df9f 100644 --- a/R/tar_process.R +++ b/R/tar_process.R @@ -40,7 +40,7 @@ tar_process <- function( names = NULL, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_process") + tar_assert_allow_meta("tar_process", store) tar_assert_scalar(store) tar_assert_chr(store) tar_assert_nzchar(store) diff --git a/R/tar_progress.R b/R/tar_progress.R index 124de05ee..040fb022a 100644 --- a/R/tar_progress.R +++ b/R/tar_progress.R @@ -42,7 +42,7 @@ tar_progress <- function( fields = "progress", store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_progress") + tar_assert_allow_meta("tar_progress", store) tar_assert_scalar(store) tar_assert_chr(store) tar_assert_nzchar(store) diff --git a/R/tar_progress_branches.R b/R/tar_progress_branches.R index b6bb53b4f..dbf047305 100644 --- a/R/tar_progress_branches.R +++ b/R/tar_progress_branches.R @@ -38,7 +38,7 @@ tar_progress_branches <- function( fields = NULL, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_progress_branches") + tar_assert_allow_meta("tar_progress_branches", store) tar_assert_scalar(store) tar_assert_chr(store) tar_assert_nzchar(store) diff --git a/R/tar_progress_summary.R b/R/tar_progress_summary.R index 225c2cc1b..8ed8206dc 100644 --- a/R/tar_progress_summary.R +++ b/R/tar_progress_summary.R @@ -33,7 +33,7 @@ tar_progress_summary <- function( fields = c("skipped", "started", "built", "errored", "canceled", "since"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_progress_summary") + tar_assert_allow_meta("tar_progress_summary", store) tar_assert_scalar(store) tar_assert_chr(store) tar_assert_nzchar(store) diff --git a/R/tar_prune.R b/R/tar_prune.R index 9250710a6..12b6a7424 100644 --- a/R/tar_prune.R +++ b/R/tar_prune.R @@ -45,7 +45,7 @@ tar_prune <- function( script = targets::tar_config_get("script"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_prune") + tar_assert_allow_meta("tar_prune", store) force(envir) tar_assert_callr_function(callr_function) tar_assert_list(callr_arguments) diff --git a/R/tar_prune_list.R b/R/tar_prune_list.R index f1fdb2599..325c51a39 100644 --- a/R/tar_prune_list.R +++ b/R/tar_prune_list.R @@ -34,7 +34,7 @@ tar_prune_list <- function( script = targets::tar_config_get("script"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_prune_list") + tar_assert_allow_meta("tar_prune_list", store) force(envir) tar_assert_callr_function(callr_function) tar_assert_list(callr_arguments) diff --git a/R/tar_read.R b/R/tar_read.R index ecba81e7c..aa3654936 100644 --- a/R/tar_read.R +++ b/R/tar_read.R @@ -24,7 +24,7 @@ tar_read <- function( meta = tar_meta(store = store), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_read") + tar_assert_allow_meta("tar_read", store) tar_assert_store(store = store) force(meta) name <- tar_deparse_language(substitute(name)) diff --git a/R/tar_read_raw.R b/R/tar_read_raw.R index e7790a84c..7dc7ef525 100644 --- a/R/tar_read_raw.R +++ b/R/tar_read_raw.R @@ -31,7 +31,7 @@ tar_read_raw <- function( meta = tar_meta(store = store), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_read_raw") + tar_assert_allow_meta("tar_read_raw", store) tar_assert_store(store = store) force(meta) tar_assert_chr(name) diff --git a/R/tar_renv.R b/R/tar_renv.R index c6eb6edfe..95073b11d 100644 --- a/R/tar_renv.R +++ b/R/tar_renv.R @@ -84,7 +84,7 @@ tar_renv <- function( envir = parent.frame(), script = targets::tar_config_get("script") ) { - tar_assert_allow_meta("tar_renv") + tar_assert_allow_meta("tar_renv", store) force(envir) tar_assert_chr(extras) tar_assert_chr(path) diff --git a/R/tar_reprex.R b/R/tar_reprex.R index 8a2461043..e8b4adcfb 100644 --- a/R/tar_reprex.R +++ b/R/tar_reprex.R @@ -36,7 +36,7 @@ tar_reprex <- function( run = tar_make(), ... ) { - tar_assert_allow_meta("tar_reprex") + tar_assert_allow_meta("tar_reprex", store) tar_assert_package("reprex") library <- "library(targets)" pipeline <- as.call(list(quote(tar_script), substitute(pipeline))) diff --git a/R/tar_sitrep.R b/R/tar_sitrep.R index dbfa56275..c2b6138d0 100644 --- a/R/tar_sitrep.R +++ b/R/tar_sitrep.R @@ -101,7 +101,7 @@ tar_sitrep <- function( script = targets::tar_config_get("script"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_sitrep") + tar_assert_allow_meta("tar_sitrep", store) force(envir) names_quosure <- rlang::enquo(names) fields_quosure <- rlang::enquo(fields) diff --git a/R/tar_skipped.R b/R/tar_skipped.R index 820f6f9e2..a704a6aad 100644 --- a/R/tar_skipped.R +++ b/R/tar_skipped.R @@ -26,7 +26,7 @@ tar_skipped <- function( names = NULL, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_skipped") + tar_assert_allow_meta("tar_skipped", store) progress <- progress_init(path_store = store) progress <- tibble::as_tibble(progress$database$read_condensed_data()) names_quosure <- rlang::enquo(names) diff --git a/R/tar_source.R b/R/tar_source.R index 8635a4153..bbbb0d82c 100644 --- a/R/tar_source.R +++ b/R/tar_source.R @@ -38,7 +38,7 @@ tar_source <- function( envir = targets::tar_option_get("envir"), change_directory = FALSE ) { - tar_assert_allow_meta("tar_source") + tar_assert_allow_meta("tar_source", store) tar_assert_lgl(change_directory) tar_assert_scalar(change_directory) tar_assert_chr(files) diff --git a/R/tar_started.R b/R/tar_started.R index f454ba2f8..7f75aca64 100644 --- a/R/tar_started.R +++ b/R/tar_started.R @@ -26,7 +26,7 @@ tar_started <- function( names = NULL, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_started") + tar_assert_allow_meta("tar_started", store) progress <- progress_init(path_store = store) progress <- tibble::as_tibble(progress$database$read_condensed_data()) names_quosure <- rlang::enquo(names) diff --git a/R/tar_traceback.R b/R/tar_traceback.R index 7fb1a4801..d5bda6e77 100644 --- a/R/tar_traceback.R +++ b/R/tar_traceback.R @@ -42,7 +42,7 @@ tar_traceback <- function( characters = getOption("width"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_traceback") + tar_assert_allow_meta("tar_traceback", store) tar_assert_scalar(characters, "characters must have length 1.") tar_assert_dbl(characters, "characters must be numeric.") tar_assert_positive(characters, "characters must be positive.") diff --git a/R/tar_unscript.R b/R/tar_unscript.R index ebf415fbf..cd38c4356 100644 --- a/R/tar_unscript.R +++ b/R/tar_unscript.R @@ -26,7 +26,7 @@ #' tar_unscript() #' }) tar_unscript <- function(script = targets::tar_config_get("script")) { - tar_assert_allow_meta("tar_unscript") + tar_assert_allow_meta("tar_unscript", store) if (!tar_exist_script(script = script)) { return(invisible()) } diff --git a/R/tar_validate.R b/R/tar_validate.R index 3d5112f78..20eaa7eb2 100644 --- a/R/tar_validate.R +++ b/R/tar_validate.R @@ -62,7 +62,7 @@ tar_validate <- function( script = targets::tar_config_get("script"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_validate") + tar_assert_allow_meta("tar_validate", store) force(envir) tar_assert_callr_function(callr_function) tar_assert_list(callr_arguments, "callr_arguments mut be a list.") diff --git a/R/tar_visnetwork.R b/R/tar_visnetwork.R index b72552040..afa49fcb3 100644 --- a/R/tar_visnetwork.R +++ b/R/tar_visnetwork.R @@ -49,7 +49,7 @@ tar_visnetwork <- function( script = targets::tar_config_get("script"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_visnetwork") + tar_assert_allow_meta("tar_visnetwork", store) force(envir) tar_assert_package("visNetwork") tar_assert_lgl(targets_only, "targets_only must be logical.") diff --git a/R/tar_watch.R b/R/tar_watch.R index 23f6e9015..3d80b8d2a 100644 --- a/R/tar_watch.R +++ b/R/tar_watch.R @@ -72,7 +72,6 @@ tar_watch <- function( stdout = "|", stderr = "|" ) { - tar_assert_allow_meta("tar_watch") tar_assert_watch_packages() tar_assert_chr(exclude) tar_assert_dbl(seconds) diff --git a/R/tar_watch_server.R b/R/tar_watch_server.R index c5450e184..f564aa1ea 100644 --- a/R/tar_watch_server.R +++ b/R/tar_watch_server.R @@ -18,7 +18,6 @@ tar_watch_server <- function( config = Sys.getenv("TAR_CONFIG", "_targets.yaml"), project = Sys.getenv("TAR_PROJECT", "main") ) { - tar_assert_allow_meta("tar_watch_server") tar_assert_watch_packages() tar_assert_chr( exclude, diff --git a/R/tar_workspace.R b/R/tar_workspace.R index 5719dc612..b93e2a87c 100644 --- a/R/tar_workspace.R +++ b/R/tar_workspace.R @@ -58,7 +58,7 @@ tar_workspace <- function( script = targets::tar_config_get("script"), store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_workspace") + tar_assert_allow_meta("tar_workspace", store) force(envir) name <- tar_deparse_language(substitute(name)) tar_assert_chr(name) diff --git a/R/tar_workspaces.R b/R/tar_workspaces.R index 874eac6de..edd1259c7 100644 --- a/R/tar_workspaces.R +++ b/R/tar_workspaces.R @@ -28,7 +28,7 @@ tar_workspaces <- function( names = NULL, store = targets::tar_config_get("store") ) { - tar_assert_allow_meta("tar_workspaces") + tar_assert_allow_meta("tar_workspaces", store) dir <- path_workspaces_dir(path_store = store) choices <- if_any( dir.exists(dir), diff --git a/R/use_targets.R b/R/use_targets.R index da3c0c60f..f7994992b 100644 --- a/R/use_targets.R +++ b/R/use_targets.R @@ -78,7 +78,6 @@ use_targets <- function( overwrite = FALSE, job_name = targets::tar_random_name() ) { - tar_assert_allow_meta("use_targets") schedulers <- c( "multicore", "multiprocess", diff --git a/R/use_targets_rmd.R b/R/use_targets_rmd.R index a9c60513d..06b90a2ef 100644 --- a/R/use_targets_rmd.R +++ b/R/use_targets_rmd.R @@ -18,7 +18,6 @@ use_targets_rmd <- function(path = "_targets.Rmd", open = interactive()) { # Covered in tests/interactive/test-use_targets_rmd.R. # nocov start - tar_assert_allow_meta("use_targets_rmd") tar_assert_package("usethis") source <- file.path( "..", diff --git a/R/utils_assert.R b/R/utils_assert.R index f449490db..efc52ee73 100644 --- a/R/utils_assert.R +++ b/R/utils_assert.R @@ -731,9 +731,15 @@ tar_assert_watch_packages <- function() { } # nocov end -tar_assert_allow_meta <- function(fun) { +tar_assert_allow_meta <- function(fun, store) { target <- tar_runtime$target - if (is.null(target)) { + safe <- is.null(target) || + is.null(tar_runtime$store) || + !identical( + normalizePath(as.character(store), mustWork = FALSE), + normalizePath(as.character(tar_runtime$store), mustWork = FALSE) + ) + if (safe) { return() } if (!target_allow_meta(target)) { @@ -742,9 +748,11 @@ tar_assert_allow_meta <- function(fun) { target$settings$name, " attempted to run targets::", fun, - "() during a pipeline, which is unsupported ", + "() to during a pipeline, which is unsupported ", "except when format %in% c(\"file\", \"file_fast\") and ", - "repository == \"local\". This is because functions like ", + "repository == \"local\", or if you are reading from a data store ", + "that does not belong to the current pipeline. ", + "This is because functions like ", fun, "() attempt to access or modify the local data store, ", "which may not exist or be properly synced in certain situations. ", diff --git a/tests/testthat/test-utils_assert.R b/tests/testthat/test-utils_assert.R index 930c9c83e..5a9b3b0e2 100644 --- a/tests/testthat/test-utils_assert.R +++ b/tests/testthat/test-utils_assert.R @@ -386,14 +386,21 @@ tar_test("tar_assert_objects_files()", { tar_test("tar_assert_allow_meta()", { old_target <- tar_runtime$target - on.exit(tar_runtime$target <- old_target) + old_store <- tar_runtime$store + on.exit({ + tar_runtime$target <- old_target + tar_runtime$store <- old_store + }) tar_runtime$target <- NULL - expect_null(tar_assert_allow_meta("fun")) + tar_runtime$store <- NULL + store <- path_store_default() + expect_null(tar_assert_allow_meta("fun", store)) tar_runtime$target <- tar_target(x, 1, format = "file", repository = "local") - expect_null(tar_assert_allow_meta("fun")) + tar_runtime$store <- store + expect_null(tar_assert_allow_meta("fun", store)) tar_runtime$target <- tar_target(x, 1, format = "rds", repository = "aws") expect_error( - tar_assert_allow_meta("fun"), + tar_assert_allow_meta("fun", store), class = "tar_condition_validate" ) })