From c57cdfcf08dafa59b0fe40f045547ad4fa531a28 Mon Sep 17 00:00:00 2001 From: wlandau-lilly Date: Wed, 15 May 2024 11:36:46 -0400 Subject: [PATCH] Remove environment unlocking and export S3 methods --- DESCRIPTION | 2 +- NAMESPACE | 158 +++++++++++++++++++++++++++++++++++++- NEWS.md | 5 ++ R/cache.R | 4 + R/create_drake_spec.R | 7 ++ R/decorate_storr.R | 26 +++++++ R/drake_config.R | 17 ++-- R/drake_meta_.R | 7 ++ R/dynamic.R | 15 ++++ R/handle_triggers.R | 6 ++ R/hpc.R | 8 ++ R/local_build.R | 47 +++--------- R/logger.R | 8 ++ R/make.R | 9 +++ R/manage_memory.R | 11 +++ R/outdated.R | 2 + R/package.R | 2 - R/store_outputs.R | 12 +++ R/transform_plan.R | 34 +++++++- man/drake-package.Rd | 1 - man/drake_config.Rd | 13 +--- man/make.Rd | 11 +-- man/new_drake_settings.Rd | 11 +-- src/unlock_environment.c | 39 ---------- 24 files changed, 337 insertions(+), 118 deletions(-) delete mode 100644 src/unlock_environment.c diff --git a/DESCRIPTION b/DESCRIPTION index b5ad5e078..55bd4638c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -153,4 +153,4 @@ Suggests: Encoding: UTF-8 Language: en-US Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE index ba1a8752c..ac48457b8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,130 @@ # Generated by roxygen2: do not edit by hand S3method("[",expr_list) +S3method(assert_format_impl,default) +S3method(assert_format_impl,diskframe) +S3method(assert_format_impl,file) +S3method(assert_format_impl,fst) +S3method(assert_format_impl,fst_dt) +S3method(assert_format_impl,fst_tbl) +S3method(assert_format_impl,keras) +S3method(assert_format_impl,qs) +S3method(assert_format_impl,rds) +S3method(assert_good_transform,default) +S3method(assert_good_transform,map) S3method(c,expr_list) +S3method(cds_assert_trace,default) +S3method(cds_assert_trace,dynamic) +S3method(cds_assert_trace,group) +S3method(cds_dynamic_deps,default) +S3method(cds_dynamic_deps,dynamic) +S3method(cds_dynamic_trace,default) +S3method(cds_dynamic_trace,dynamic) +S3method(char,transform) +S3method(chr_dynamic_impl,default) +S3method(chr_dynamic_impl,drake_dynamic) +S3method(conclude_build_impl,default) +S3method(conclude_build_impl,drake_cancel) +S3method(dcst_get_,default) +S3method(dcst_get_,drake_format_diskframe) +S3method(dcst_get_,drake_format_file) +S3method(dcst_get_,drake_format_fst) +S3method(dcst_get_,drake_format_fst_dt) +S3method(dcst_get_,drake_format_fst_tbl) +S3method(dcst_get_,drake_format_keras) +S3method(dcst_get_,drake_format_qs) +S3method(dcst_get_,drake_format_rds) +S3method(dcst_get_value_,default) +S3method(dcst_get_value_,drake_format_diskframe) +S3method(dcst_get_value_,drake_format_file) +S3method(dcst_get_value_,drake_format_fst) +S3method(dcst_get_value_,drake_format_fst_dt) +S3method(dcst_get_value_,drake_format_fst_tbl) +S3method(dcst_get_value_,drake_format_keras) +S3method(dcst_get_value_,drake_format_qs) +S3method(dcst_get_value_,drake_format_rds) +S3method(dcst_set,default) +S3method(dcst_set,drake_format_diskframe) +S3method(dcst_set,drake_format_fst) +S3method(dcst_set,drake_format_fst_dt) +S3method(dcst_set,drake_format_fst_tbl) +S3method(dcst_set,drake_format_keras) +S3method(dcst_set,drake_format_qs) +S3method(dcst_set,drake_format_rds) +S3method(decorate_format_meta,default) +S3method(decorate_format_meta,drake_format_file) +S3method(decorate_format_value,default) +S3method(decorate_format_value,drake_format_file) +S3method(decorate_trigger_format_meta,default) +S3method(decorate_trigger_format_meta,file) +S3method(drake_meta_impl,dynamic) +S3method(drake_meta_impl,imported_file) +S3method(drake_meta_impl,imported_object) +S3method(drake_meta_impl,static) +S3method(drake_meta_impl,subtarget) +S3method(dsl_by,combine) +S3method(dsl_combine,combine) +S3method(dsl_deps,combine) +S3method(dsl_deps,cross) +S3method(dsl_deps,map) +S3method(dsl_grid,cross) +S3method(dsl_grid,map) +S3method(dsl_id,transform) +S3method(dsl_names,transform) +S3method(dsl_revdeps,combine) +S3method(dsl_revdeps,cross) +S3method(dsl_revdeps,map) +S3method(dsl_transform,combine) +S3method(dsl_transform,map) +S3method(dynamic_hash_list,cross) +S3method(dynamic_hash_list,group) +S3method(dynamic_hash_list,map) +S3method(dynamic_hashes,default) +S3method(dynamic_hashes,drake_dynamic) +S3method(find_old_groupings,combine) +S3method(find_old_groupings,cross) +S3method(find_old_groupings,map) +S3method(format_file_checksum_impl,default) +S3method(format_file_checksum_impl,file) +S3method(get_subtargets,default) +S3method(get_subtargets,drake_dynamic) +S3method(get_trace_impl,cross) +S3method(get_trace_impl,group) +S3method(get_trace_impl,map) +S3method(groupings,combine) +S3method(groupings,map) +S3method(handle_triggers_impl,dynamic_registered) +S3method(handle_triggers_impl,dynamic_unregistered) +S3method(handle_triggers_impl,static) +S3method(handle_triggers_impl,subtarget) +S3method(hpc_spec_impl,default) +S3method(hpc_spec_impl,subtarget) +S3method(interpret_transform,combine) +S3method(interpret_transform,cross) +S3method(interpret_transform,map) +S3method(is_outdated_impl,dynamic) +S3method(is_outdated_impl,static) +S3method(lang,command) +S3method(load_dynamic_subdep_impl,default) +S3method(load_dynamic_subdep_impl,group) +S3method(load_target_impl,bind) +S3method(load_target_impl,eager) +S3method(load_target_impl,promise) +S3method(load_targets_impl,default) +S3method(load_targets_impl,drake_dynamic) +S3method(manage_deps,autoclean) +S3method(manage_deps,lookahead) +S3method(manage_deps,none) +S3method(manage_deps,preclean) +S3method(manage_deps,speed) +S3method(manage_deps,unload) +S3method(match_dynamic_call_impl,combine) +S3method(match_dynamic_call_impl,cross) +S3method(match_dynamic_call_impl,group) +S3method(match_dynamic_call_impl,map) +S3method(new_groupings,cross) +S3method(new_groupings,map) +S3method(old_groupings,map) S3method(plot,drake_plan) S3method(print,drake_config) S3method(print,drake_deps) @@ -13,9 +136,43 @@ S3method(print,drake_plan_source) S3method(print,drake_settings) S3method(print,drake_spec) S3method(print,drake_triggers) +S3method(recovery_key_impl,default) +S3method(recovery_key_impl,subtarget) +S3method(sanitize_format,default) +S3method(sanitize_format,drake_format_diskframe) +S3method(sanitize_format,drake_format_file) +S3method(sanitize_format,drake_format_fst) +S3method(sanitize_format,drake_format_fst_dt) +S3method(sanitize_format,drake_format_fst_tbl) +S3method(serialize_build,default) +S3method(serialize_build,drake_build_keras) +S3method(store_item_impl,drake_function) +S3method(store_item_impl,drake_object) +S3method(store_item_impl,drake_static_storage) +S3method(store_item_impl,drake_storr) S3method(subtarget_deps,cross) S3method(subtarget_deps,group) S3method(subtarget_deps,map) +S3method(subtarget_hashes,cross) +S3method(subtarget_hashes,group) +S3method(subtarget_hashes,map) +S3method(tag_in,transform) +S3method(tag_out,transform) +S3method(target_msg,cancel) +S3method(target_msg,dynamic) +S3method(target_msg,fail) +S3method(target_msg,finalize) +S3method(target_msg,recover) +S3method(target_msg,retry) +S3method(target_msg,subtarget) +S3method(target_msg,target) +S3method(undecorate_format_value,default) +S3method(undecorate_format_value,drake_format) +S3method(unserialize_build,default) +S3method(unserialize_build,drake_build_keras) +S3method(value_format,default) +S3method(value_format,drake_format) +S3method(value_format,drake_format_diskframe) export(Makefile_recipe) export(all_of) export(analyses) @@ -312,4 +469,3 @@ importFrom(vctrs,new_rcrd) importFrom(vctrs,vec_assert) importFrom(vctrs,vec_c) importFrom(vctrs,vec_slice) -useDynLib(drake, .registration = TRUE) diff --git a/NEWS.md b/NEWS.md index 29fd7cae8..fa1231496 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# Version 7.13.10 + +* Remove environment locking, c.f. https://github.com/r-lib/rlang/issues/1705. +* Export S3 methods. + # Version 7.13.9 * Avoid `is.R()`. diff --git a/R/cache.R b/R/cache.R index e8cbec3ee..c910ad6c6 100644 --- a/R/cache.R +++ b/R/cache.R @@ -315,6 +315,7 @@ load_targets_impl <- function( UseMethod("load_targets_impl") } +#' @export load_targets_impl.drake_dynamic <- function( # nolint hashes, target, @@ -328,6 +329,7 @@ load_targets_impl.drake_dynamic <- function( # nolint assign(target, value, envir = envir, inherits = FALSE) } +#' @export load_targets_impl.default <- function( hashes, target, @@ -343,6 +345,7 @@ get_subtargets <- function(hashes, target, cache, subtargets, subtarget_list) { UseMethod("get_subtargets") } +#' @export get_subtargets.drake_dynamic <- function( hashes, target, @@ -366,6 +369,7 @@ get_subtargets.drake_dynamic <- function( out } +#' @export get_subtargets.default <- function( hashes, target, diff --git a/R/create_drake_spec.R b/R/create_drake_spec.R index 8cc79fbc1..0c1a39403 100644 --- a/R/create_drake_spec.R +++ b/R/create_drake_spec.R @@ -295,6 +295,7 @@ cds_dynamic_deps <- function(dynamic, target, args) { UseMethod("cds_dynamic_deps") } +#' @export cds_dynamic_deps.dynamic <- function(dynamic, target, args) { dynamic$.trace <- NULL out <- ht_filter(args$ht_globals, all.vars(dynamic)) @@ -307,6 +308,7 @@ cds_dynamic_deps.dynamic <- function(dynamic, target, args) { out } +#' @export cds_dynamic_deps.default <- function(dynamic, target, args) { character(0) } @@ -315,10 +317,12 @@ cds_dynamic_trace <- function(dynamic, args) { UseMethod("cds_dynamic_trace") } +#' @export cds_dynamic_trace.dynamic <- function(dynamic, args) { all.vars(dynamic$.trace) } +#' @export cds_dynamic_trace.default <- function(dynamic, args) { character(0) } @@ -327,6 +331,7 @@ cds_assert_trace <- function(dynamic, spec) { UseMethod("cds_assert_trace") } +#' @export cds_assert_trace.group <- function(dynamic, spec) { bad <- setdiff(spec$deps_dynamic_trace, spec$deps_dynamic) if (!length(bad)) { @@ -343,6 +348,7 @@ cds_assert_trace.group <- function(dynamic, spec) { ) } +#' @export cds_assert_trace.dynamic <- function(dynamic, spec) { bad <- setdiff(spec$deps_dynamic_trace, spec$deps_dynamic) if (!length(bad)) { @@ -360,6 +366,7 @@ cds_assert_trace.dynamic <- function(dynamic, spec) { ) } +#' @export cds_assert_trace.default <- function(dynamic, spec) { character(0) } diff --git a/R/decorate_storr.R b/R/decorate_storr.R index 95e307996..23a414688 100644 --- a/R/decorate_storr.R +++ b/R/decorate_storr.R @@ -289,15 +289,18 @@ dcst_get_ <- function(value, key, .self) { UseMethod("dcst_get_") } +#' @export dcst_get_.default <- function(value, key, .self) { value } +#' @export dcst_get_.drake_format_fst <- function(value, key, .self) { assert_pkg("fst") fst::read_fst(.self$file_return_key(key)) } +#' @export dcst_get_.drake_format_fst_tbl <- function(value, key, .self) { assert_pkg("fst") assert_pkg("tibble") @@ -305,18 +308,21 @@ dcst_get_.drake_format_fst_tbl <- function(value, key, .self) { tibble::as_tibble(out) } +#' @export dcst_get_.drake_format_fst_dt <- function(value, key, .self) { # nolint assert_pkg("data.table") assert_pkg("fst") fst::read_fst(.self$file_return_key(key), as.data.table = TRUE) } +#' @export dcst_get_.drake_format_diskframe <- function(value, key, .self) { # nolint assert_pkg("disk.frame") assert_pkg("fst") disk.frame::disk.frame(.self$file_return_key(key), backend = "fst") } +#' @export dcst_get_.drake_format_qs <- function(value, key, .self) { # nolint assert_pkg("qs") qs::qread( @@ -329,16 +335,19 @@ dcst_get_.drake_format_qs <- function(value, key, .self) { # nolint # Requires Python Keras and TensorFlow to test. Tested in test-keras.R. # nocov start +#' @export dcst_get_.drake_format_keras <- function(value, key, .self) { assert_pkg("keras") keras::load_model_hdf5(.self$file_return_key(key)) } # nocov end +#' @export dcst_get_.drake_format_rds <- function(value, key, .self) { readRDS(.self$file_return_key(key)) } +#' @export dcst_get_.drake_format_file <- function(value, key, .self) { value$value } @@ -352,15 +361,18 @@ dcst_get_value_ <- function(value, hash, .self) { UseMethod("dcst_get_value_") } +#' @export dcst_get_value_.default <- function(value, hash, .self) { value } +#' @export dcst_get_value_.drake_format_fst <- function(value, hash, .self) { # nolint assert_pkg("fst") fst::read_fst(.self$file_return_hash(hash)) } +#' @export dcst_get_value_.drake_format_fst_tbl <- function(value, hash, .self) { # nolint assert_pkg("fst") assert_pkg("tibble") @@ -368,18 +380,21 @@ dcst_get_value_.drake_format_fst_tbl <- function(value, hash, .self) { # nolint tibble::as_tibble(out) } +#' @export dcst_get_value_.drake_format_fst_dt <- function(value, hash, .self) { # nolint assert_pkg("data.table") assert_pkg("fst") fst::read_fst(.self$file_return_hash(hash), as.data.table = TRUE) } +#' @export dcst_get_value_.drake_format_diskframe <- function(value, hash, .self) { # nolint assert_pkg("disk.frame") assert_pkg("fst") disk.frame::disk.frame(.self$file_return_hash(hash), backend = "fst") } +#' @export dcst_get_value_.drake_format_qs <- function(value, hash, .self) { # nolint assert_pkg("qs") qs::qread( @@ -392,16 +407,19 @@ dcst_get_value_.drake_format_qs <- function(value, hash, .self) { # nolint # Requires Python Keras and TensorFlow to test. Tested in test-keras.R. # nocov start +#' @export dcst_get_value_.drake_format_keras <- function(value, hash, .self) { # nolint assert_pkg("keras") keras::load_model_hdf5(.self$file_return_hash(hash)) } # nocov end +#' @export dcst_get_value_.drake_format_rds <- function(value, hash, .self) { # nolint readRDS(.self$file_return_hash(hash)) } +#' @export dcst_get_value_.drake_format_file <- function(value, hash, .self) { # nolint value$value } @@ -410,10 +428,12 @@ dcst_set <- function(value, key, ..., .self) { UseMethod("dcst_set") } +#' @export dcst_set.default <- function(value, key, ..., .self) { suppressWarnings(.self$storr$set(key = key, value = value, ...)) } +#' @export dcst_set.drake_format_fst <- function(value, key, ..., .self) { assert_pkg("fst") .self$assert_dirs() @@ -423,8 +443,10 @@ dcst_set.drake_format_fst <- function(value, key, ..., .self) { dcst_set_move_tmp(key = key, value = value, tmp = tmp, .self = .self) } +#' @export dcst_set.drake_format_fst_tbl <- dcst_set.drake_format_fst +#' @export dcst_set.drake_format_fst_dt <- function(value, key, ..., .self) { assert_pkg("data.table") assert_pkg("fst") @@ -435,6 +457,7 @@ dcst_set.drake_format_fst_dt <- function(value, key, ..., .self) { dcst_set_move_tmp(key = key, value = value, tmp = tmp, .self = .self) } +#' @export dcst_set.drake_format_diskframe <- function(value, key, ..., .self) { # nolint assert_pkg("disk.frame") assert_pkg("fst") @@ -444,6 +467,7 @@ dcst_set.drake_format_diskframe <- function(value, key, ..., .self) { # nolint dcst_set_move_tmp(key = key, value = value, tmp = tmp, .self = .self) } +#' @export dcst_set.drake_format_qs <- function(value, key, ..., .self) { # nolint assert_pkg("qs") .self$assert_dirs() @@ -463,6 +487,7 @@ dcst_set.drake_format_qs <- function(value, key, ..., .self) { # nolint # Requires Python Keras and TensorFlow to test. Tested in test-test-keras.R # nocov start +#' @export dcst_set.drake_format_keras <- function(value, key, ..., .self) { assert_pkg("keras") .self$assert_dirs() @@ -473,6 +498,7 @@ dcst_set.drake_format_keras <- function(value, key, ..., .self) { } # nocov end +#' @export dcst_set.drake_format_rds <- function(value, key, ..., .self) { .self$assert_dirs() stopifnot(getRversion() >= "3.5.0") # for ALTREP diff --git a/R/drake_config.R b/R/drake_config.R index 444846c26..1ae196e2a 100644 --- a/R/drake_config.R +++ b/R/drake_config.R @@ -372,15 +372,8 @@ #' #' @param layout Deprecated. #' -#' @param lock_envir Logical, whether to lock `config$envir` during `make()`. -#' If `TRUE`, `make()` quits in error whenever a command in your -#' `drake` plan (or `prework`) tries to add, remove, or modify -#' non-hidden variables in your environment/workspace/R session. -#' This is extremely important for ensuring the purity of your functions -#' and the reproducibility/credibility/trust you can place in your project. -#' `lock_envir` will be set to a default of `TRUE` in `drake` version -#' 7.0.0 and higher. Namespaces are never locked, e.g. -#' if `envir` is `getNamespace("packagename")`. +#' @param lock_envir Deprecated in `drake >= 7.13.10`. Environments +#' are no longer locked. #' #' @param history Logical, whether to record the build history #' of your targets. You can also supply a @@ -551,7 +544,7 @@ drake_config <- function( memory_strategy = "speed", spec = NULL, layout = NULL, - lock_envir = TRUE, + lock_envir = NULL, history = TRUE, recover = FALSE, recoverable = TRUE, @@ -582,6 +575,10 @@ drake_config <- function( deprecate_arg(makefile_path, "makefile_path") deprecate_arg(layout, "layout", "spec") # 2019-12-15 deprecate_arg(console_log_file, "console_log_file", "log_make") # 2020-02-08 + deprecate_arg(lock_envir, "lock_envir") + if (is.null(lock_envir)) { + lock_envir <- FALSE + } if (identical(caching, "master")) { caching <- "main" warn0( diff --git a/R/drake_meta_.R b/R/drake_meta_.R index 027779277..e15c95e55 100644 --- a/R/drake_meta_.R +++ b/R/drake_meta_.R @@ -72,6 +72,7 @@ drake_meta_impl <- function(target, config) { UseMethod("drake_meta_impl") } +#' @export drake_meta_impl.imported_file <- function(target, config) { # nolint spec <- config$spec[[target]] meta <- list( @@ -91,6 +92,7 @@ drake_meta_impl.imported_file <- function(target, config) { # nolint meta } +#' @export drake_meta_impl.imported_object <- function(target, config) { # nolint spec <- config$spec[[target]] meta <- list( @@ -108,6 +110,7 @@ drake_meta_impl.imported_object <- function(target, config) { # nolint meta } +#' @export drake_meta_impl.subtarget <- function(target, config) { parent_spec <- config$spec[[subtarget_parent(target, config)]] list( @@ -123,6 +126,7 @@ drake_meta_impl.subtarget <- function(target, config) { ) } +#' @export drake_meta_impl.dynamic <- function(target, config) { spec <- config$spec[[target]] meta <- list( @@ -215,6 +219,7 @@ dynamic_progress_ns_pfx <- function(target) { paste0("dyn-", target, "-") } +#' @export drake_meta_impl.static <- function(target, config) { spec <- config$spec[[target]] meta <- list( @@ -258,10 +263,12 @@ decorate_trigger_format_meta <- function(target, meta, config) { UseMethod("decorate_trigger_format_meta") } +#' @export decorate_trigger_format_meta.default <- function(target, meta, config) { # nolint meta } +#' @export decorate_trigger_format_meta.file <- function(target, meta, config) { # nolint meta_old <- config$meta_old[[target]] if (is.null(meta_old) || !meta$trigger$file) { diff --git a/R/dynamic.R b/R/dynamic.R index 7a5c9a2f7..38c3e900d 100644 --- a/R/dynamic.R +++ b/R/dynamic.R @@ -151,6 +151,7 @@ get_trace_impl <- function(dynamic, value, spec, config) { UseMethod("get_trace_impl") } +#' @export get_trace_impl.map <- function(dynamic, value, spec, config) { trace <- lapply( spec$deps_dynamic_trace, @@ -163,6 +164,7 @@ get_trace_impl.map <- function(dynamic, value, spec, config) { trace } +#' @export get_trace_impl.cross <- function(dynamic, value, spec, config) { size <- lapply( spec$deps_dynamic, @@ -187,6 +189,7 @@ get_trace_impl.cross <- function(dynamic, value, spec, config) { trace } +#' @export get_trace_impl.group <- function(dynamic, value, spec, config) { by_key <- which_by(dynamic) by_value <- get(by_key, envir = config$envir_targets, inherits = FALSE) @@ -203,10 +206,12 @@ chr_dynamic_impl <- function(x) { UseMethod("chr_dynamic_impl") } +#' @export chr_dynamic_impl.drake_dynamic <- function(x) { as.character(x) } +#' @export chr_dynamic_impl.default <- function(x) { x } @@ -427,12 +432,15 @@ match_dynamic_call_impl <- function(dynamic) { UseMethod("match_dynamic_call_impl") } +#' @export match_dynamic_call_impl.map <- function(dynamic) { match.call(definition = def_map, call = dynamic) } +#' @export match_dynamic_call_impl.cross <- match_dynamic_call_impl.map +#' @export match_dynamic_call_impl.combine <- function(dynamic) { # nolint stop0( "Dynamic combine() does not exist. ", @@ -441,6 +449,7 @@ match_dynamic_call_impl.combine <- function(dynamic) { # nolint ) } +#' @export match_dynamic_call_impl.group <- function(dynamic) { match.call(definition = def_group, call = dynamic) } @@ -483,6 +492,7 @@ dynamic_hash_list <- function(dynamic, target, config) { UseMethod("dynamic_hash_list") } +#' @export dynamic_hash_list.map <- function(dynamic, target, config) { deps <- sort(config$spec[[target]]$deps_dynamic) hashes <- lapply(deps, read_dynamic_hashes, config = config) @@ -491,6 +501,7 @@ dynamic_hash_list.map <- function(dynamic, target, config) { hashes } +#' @export dynamic_hash_list.cross <- function(dynamic, target, config) { deps <- config$spec[[target]]$deps_dynamic hashes <- lapply(deps, read_dynamic_hashes, config = config) @@ -498,6 +509,7 @@ dynamic_hash_list.cross <- function(dynamic, target, config) { hashes } +#' @export dynamic_hash_list.group <- function(dynamic, target, config) { deps <- sort(which_vars(dynamic)) out <- lapply(deps, read_dynamic_hashes, config = config) @@ -544,10 +556,12 @@ subtarget_hashes <- function(dynamic, target, hashes, config) { UseMethod("subtarget_hashes") } +#' @export subtarget_hashes.map <- function(dynamic, target, hashes, config) { do.call(paste, hashes) } +#' @export subtarget_hashes.cross <- function(dynamic, target, hashes, config) { deps <- all.vars(dynamic) hashes <- hashes[deps] @@ -556,6 +570,7 @@ subtarget_hashes.cross <- function(dynamic, target, hashes, config) { apply(hashes, 1, paste, collapse = " ") } +#' @export subtarget_hashes.group <- function(dynamic, target, hashes, config) { if (is.null(hashes[["_by"]])) { return(lapply(hashes, paste, collapse = " ")) diff --git a/R/handle_triggers.R b/R/handle_triggers.R index ac462cef5..45d4e5e6e 100644 --- a/R/handle_triggers.R +++ b/R/handle_triggers.R @@ -20,14 +20,17 @@ handle_triggers_impl <- function(target, meta, config) { UseMethod("handle_triggers_impl") } +#' @export handle_triggers_impl.subtarget <- function(target, meta, config) { # nolint FALSE } +#' @export handle_triggers_impl.dynamic_registered <- function(target, meta, config) { # nolint FALSE } +#' @export handle_triggers_impl.dynamic_unregistered <- function(target, meta, config) { # nolint target <- unclass(target) static_ok <- !any_static_triggers(target, meta, config) || @@ -37,6 +40,7 @@ handle_triggers_impl.dynamic_unregistered <- function(target, meta, config) { # TRUE } +#' @export handle_triggers_impl.static <- function(target, meta, config) { # nolint target <- unclass(target) any_triggers <- any_static_triggers(target, meta, config) || @@ -113,6 +117,7 @@ recovery_key_impl <- function(target, meta, config) { UseMethod("recovery_key_impl") } +#' @export recovery_key_impl.subtarget <- function(target, meta, config) { parent <- subtarget_parent(target, config) parent_meta <- drake_meta_(parent, config) @@ -122,6 +127,7 @@ recovery_key_impl.subtarget <- function(target, meta, config) { config$cache$digest(x, serialize = FALSE) } +#' @export recovery_key_impl.default <- function(target, meta, config, ...) { change_hash <- ifelse( is.null(meta$trigger$value), diff --git a/R/hpc.R b/R/hpc.R index 398f1b227..64798aba9 100644 --- a/R/hpc.R +++ b/R/hpc.R @@ -139,6 +139,7 @@ hpc_spec_impl <- function(target, config) { UseMethod("hpc_spec_impl") } +#' @export hpc_spec_impl.subtarget <- function(target, config) { spec <- new.env(parent = emptyenv()) parent <- config$spec[[target]]$subtarget_parent @@ -150,6 +151,7 @@ hpc_spec_impl.subtarget <- function(target, config) { spec } +#' @export hpc_spec_impl.default <- function(target, config) { spec <- new.env(parent = emptyenv()) assign(target, config$spec[[target]], envir = spec, inherits = FALSE) @@ -284,11 +286,13 @@ format_file_checksum_impl <- function(target, value, config) { UseMethod("format_file_checksum_impl") } +#' @export format_file_checksum_impl.default <- function(target, value, config) { # nolint force(value) character(0) } +#' @export format_file_checksum_impl.file <- function(target, value, config) { # nolint hash <- rep(NA_character_, length(value)) index <- file.exists(value) @@ -384,6 +388,7 @@ serialize_build <- function(build) { # Requires Python Keras and TensorFlow to test. Tested in test-keras.R. # nocov start +#' @export serialize_build.drake_build_keras <- function(build) { # nolint assert_pkg("keras") build$value <- keras::serialize_model(build$value) @@ -391,6 +396,7 @@ serialize_build.drake_build_keras <- function(build) { # nolint } # nocov end +#' @export serialize_build.default <- function(build) { build } @@ -401,6 +407,7 @@ unserialize_build <- function(build) { # Requires Python Keras and TensorFlow to test. Tested in test-keras.R. # nocov start +#' @export unserialize_build.drake_build_keras <- function(build) { # nolint assert_pkg("keras") build$value <- keras::unserialize_model(build$value) @@ -408,6 +415,7 @@ unserialize_build.drake_build_keras <- function(build) { # nolint } # nocov end +#' @export unserialize_build.default <- function(build) { build } diff --git a/R/local_build.R b/R/local_build.R index ab4c5ac44..cf6aa9fe3 100644 --- a/R/local_build.R +++ b/R/local_build.R @@ -259,9 +259,7 @@ drake_with_call_stack_8a6af5 <- function(target, config) { } expr <- config$spec[[target]]$command_build if (config$settings$lock_envir && !isNamespace(config$envir)) { - on.exit(unlock_environment(config$envir)) - block_envir_lock(config) - lock_environment(config$envir) + message("Environment locking is not supported in drake >= 7.13.10") } tidy_expr_8a6af5 <- eval(expr = expr, envir = config$envir_subtargets) tryCatch( @@ -290,37 +288,6 @@ deparse_traceback <- function(traceback) { vcapply(traceback$call %|||% traceback$calls, safe_deparse) } -block_envir_lock <- function(config) { - i <- 1 - # Lock the environment only while running the command. - while (environmentIsLocked(config$envir)) { - Sys.sleep(config$settings$sleep(max(0L, i))) # nocov - i <- i + 1 # nocov - } -} - -lock_environment <- function(envir) { - lockEnvironment(envir, bindings = FALSE) - lapply(X = unhidden_names(envir), FUN = lockBinding, env = envir) - invisible() -} - -unlock_environment <- function(envir) { - if (is.null(envir)) { - stop0("use of NULL environment is defunct") - } - if (!inherits(envir, "environment")) { - stop0("not an environment") - } - .Call(Cunlock_environment, envir) - lapply( - X = unhidden_names(envir), - FUN = unlockBinding, - env = envir - ) - stopifnot(!environmentIsLocked(envir)) -} - unhidden_names <- function(envir) { out <- names(envir) out <- out[substr(out, 0, 1) != "."] @@ -353,11 +320,13 @@ conclude_build_impl <- function(value, target, meta, config) { UseMethod("conclude_build_impl") } +#' @export conclude_build_impl.drake_cancel <- function(value, target, meta, config) { # nolint config$cache$set_progress(target = target, value = "cancelled") config$logger$target(target, "cancel") } +#' @export conclude_build_impl.default <- function(value, target, meta, config) { assert_output_files(target = target, meta = meta, config = config) handle_build_exceptions(target = target, meta = meta, config = config) @@ -386,10 +355,12 @@ sanitize_format <- function(x, target, config) { UseMethod("sanitize_format") } +#' @export sanitize_format.default <- function(x, target, config) { x } +#' @export sanitize_format.drake_format_fst <- function(x, target, config) { # nolint if (!identical(class(x$value), "data.frame")) { msg <- paste0( @@ -405,6 +376,7 @@ sanitize_format.drake_format_fst <- function(x, target, config) { # nolint x } +#' @export sanitize_format.drake_format_fst_tbl <- function(x, target, config) { # nolint assert_pkg("tibble") if (!inherits(x$value, "tbl_df")) { @@ -421,6 +393,7 @@ sanitize_format.drake_format_fst_tbl <- function(x, target, config) { # nolint x } +#' @export sanitize_format.drake_format_fst_dt <- function(x, target, config) { # nolint assert_pkg("data.table") if (!inherits(x$value, "data.table")) { @@ -437,6 +410,7 @@ sanitize_format.drake_format_fst_dt <- function(x, target, config) { # nolint x } +#' @export sanitize_format.drake_format_diskframe <- function(x, target, config) { # nolint assert_pkg("disk.frame") if (!inherits(x$value, "disk.frame")) { @@ -459,6 +433,7 @@ sanitize_format.drake_format_diskframe <- function(x, target, config) { # nolint x } +#' @export sanitize_format.drake_format_file <- function(x, target, config) { # nolint if (!is.character(x$value)) { msg <- paste0( @@ -503,14 +478,17 @@ value_format <- function(value, target, config) { UseMethod("value_format") } +#' @export value_format.drake_format_diskframe <- function(value, target, config) { # nolint config$cache$get(target) } +#' @export value_format.drake_format <- function(value, target, config) { value$value } +#' @export value_format.default <- function(value, target, config) { value } @@ -588,7 +566,6 @@ log_failure <- function(target, meta, config) { msg3 <- paste0(diag, "$calls:\n", trace) msg <- paste(c(msg1, msg2, msg3), collapse = "\n") config$logger$disk(msg) - unlock_environment(config$envir) stop0(msg) } diff --git a/R/logger.R b/R/logger.R index 18ba10434..02fab8a2c 100644 --- a/R/logger.R +++ b/R/logger.R @@ -121,48 +121,56 @@ target_msg <- function(target) { } } +#' @export target_msg.finalize <- function(target) { symbol <- cli::col_green(cli::symbol$stop) msg <- paste(symbol, "finalize", target) message(msg) } +#' @export target_msg.cancel <- function(target) { symbol <- cli::col_yellow(cli::symbol$stop) msg <- paste(symbol, "cancel", target) message(msg) } +#' @export target_msg.dynamic <- function(target) { symbol <- cli::col_green(cli::symbol$play) msg <- paste(symbol, "dynamic", target) message(msg) } +#' @export target_msg.fail <- function(target) { symbol <- cli::col_red(cli::symbol$cross) msg <- paste(symbol, "fail", target) message(msg) } +#' @export target_msg.recover <- function(target) { symbol <- cli::col_green(cli::symbol$tick) msg <- paste(symbol, "recover", target) message(msg) } +#' @export target_msg.retry <- function(target) { symbol <- cli::col_yellow(cli::symbol$warning) msg <- paste(symbol, "retry", target) message(msg) } +#' @export target_msg.subtarget <- function(target) { symbol <- cli::col_green(cli::symbol$pointer) msg <- paste(symbol, "subtarget", target) message(msg) } +#' @export target_msg.target <- function(target) { symbol <- cli::col_green(cli::symbol$play) msg <- paste(symbol, "target", target) diff --git a/R/make.R b/R/make.R index bb906ff1e..33d726d89 100644 --- a/R/make.R +++ b/R/make.R @@ -521,39 +521,48 @@ assert_format_impl <- function(format) { UseMethod("assert_format_impl") } +#' @export assert_format_impl.fst <- function(format) { assert_pkg("fst") } +#' @export assert_format_impl.fst_tbl <- function(format) { assert_pkg("fst") assert_pkg("tibble") } +#' @export assert_format_impl.fst_dt <- function(format) { assert_pkg("fst") assert_pkg("data.table") } +#' @export assert_format_impl.diskframe <- function(format) { assert_pkg("disk.frame") } +#' @export assert_format_impl.keras <- function(format) { assert_pkg("keras") # nocov } +#' @export assert_format_impl.qs <- function(format) { assert_pkg("qs") } +#' @export assert_format_impl.rds <- function(format) { stopifnot(getRversion() >= "3.5.0") } +#' @export assert_format_impl.file <- function(format) { } +#' @export assert_format_impl.default <- function(format) { stop0( "illegal format ", format, ". Read ", diff --git a/R/manage_memory.R b/R/manage_memory.R index f08998d4d..4ca81e705 100644 --- a/R/manage_memory.R +++ b/R/manage_memory.R @@ -37,6 +37,7 @@ manage_deps <- function(target, config, downstream, jobs) { UseMethod("manage_deps") } +#' @export manage_deps.speed <- function(target, config, downstream, jobs) { already_loaded <- config$envir_loaded$targets memory_deps <- deps_memory(targets = target, config = config) @@ -47,6 +48,7 @@ manage_deps.speed <- function(target, config, downstream, jobs) { load_subtarget_subdeps(target, config) } +#' @export manage_deps.autoclean <- function(target, config, downstream, jobs) { already_loaded <- config$envir_loaded$targets memory_deps <- deps_memory(targets = target, config = config) @@ -59,8 +61,10 @@ manage_deps.autoclean <- function(target, config, downstream, jobs) { load_subtarget_subdeps(target, config) } +#' @export manage_deps.preclean <- manage_deps.autoclean +#' @export manage_deps.lookahead <- function(target, config, downstream, jobs) { downstream <- downstream %||% downstream_nodes( config$envir_graph$graph, @@ -79,10 +83,12 @@ manage_deps.lookahead <- function(target, config, downstream, jobs) { load_subtarget_subdeps(target, config) } +#' @export manage_deps.unload <- function(target, config, downstream, jobs) { clear_envir_targets(target = target, config = config) } +#' @export manage_deps.none <- function(target, config, downstream, jobs) { return() } @@ -195,6 +201,7 @@ load_target_impl <- function(target, cache, namespace, envir, verbose) { UseMethod("load_target_impl") } +#' @export load_target_impl.eager <- function(target, cache, namespace, envir, verbose) { value <- cache$get( key = target, @@ -207,6 +214,7 @@ load_target_impl.eager <- function(target, cache, namespace, envir, verbose) { invisible() } +#' @export load_target_impl.promise <- function(target, cache, namespace, envir, verbose) { eval_env <- environment() delayedAssign( @@ -221,6 +229,7 @@ load_target_impl.promise <- function(target, cache, namespace, envir, verbose) { ) } +#' @export load_target_impl.bind <- function(target, cache, namespace, envir, verbose) { assert_pkg("bindr") # Allow active bindings to overwrite existing variables. @@ -309,6 +318,7 @@ load_dynamic_subdep_impl <- function(dynamic, parent, dep, index, config) { UseMethod("load_dynamic_subdep_impl") } +#' @export load_dynamic_subdep_impl.group <- function( # nolint dynamic, parent, @@ -331,6 +341,7 @@ load_dynamic_subdep_impl.group <- function( # nolint ) } +#' @export load_dynamic_subdep_impl.default <- function( # nolint dynamic, parent, diff --git a/R/outdated.R b/R/outdated.R index c5bb02237..b19ced794 100644 --- a/R/outdated.R +++ b/R/outdated.R @@ -252,6 +252,7 @@ is_outdated_impl <- function(target, config) { UseMethod("is_outdated_impl") } +#' @export is_outdated_impl.static <- function(target, config) { target <- unclass(target) meta <- drake_meta_(target, config) @@ -259,6 +260,7 @@ is_outdated_impl.static <- function(target, config) { any_subtargetlike_triggers(target, meta, config) } +#' @export is_outdated_impl.dynamic <- function(target, config) { target <- unclass(target) meta <- drake_meta_(target, config) diff --git a/R/package.R b/R/package.R index 373afbca1..d35180005 100644 --- a/R/package.R +++ b/R/package.R @@ -1,5 +1,4 @@ #' drake: A pipeline toolkit for reproducible computation at scale. -#' @docType package #' @description drake is a pipeline toolkit #' (`https://github.com/pditommaso/awesome-pipeline`) #' and a scalable, R-focused solution for reproducibility @@ -44,7 +43,6 @@ #' }) #' } #' @references `https://github.com/ropensci/drake` -#' @useDynLib drake, .registration = TRUE #' @importFrom base64url base32_decode base32_encode #' @importFrom digest getVDigest #' @importFrom igraph adjacent_vertices as_ids components delete_vertices diff --git a/R/store_outputs.R b/R/store_outputs.R index eb785805d..739b35ccc 100644 --- a/R/store_outputs.R +++ b/R/store_outputs.R @@ -38,10 +38,12 @@ decorate_format_value <- function(value, target, config) { UseMethod("decorate_format_value") } +#' @export decorate_format_value.default <- function(value, target, config) { value } +#' @export decorate_format_value.drake_format_file <- function(value, target, config) { # nolint path <- value$value hash <- rep(NA_character_, length(path)) @@ -63,10 +65,12 @@ undecorate_format_value <- function(value) { UseMethod("undecorate_format_value") } +#' @export undecorate_format_value.default <- function(value) { # nolint value } +#' @export undecorate_format_value.drake_format <- function(value) { # nolint value$value } @@ -137,6 +141,7 @@ store_item_impl <- function(target, value, meta, config) { UseMethod("store_item_impl") } +#' @export store_item_impl.drake_static_storage <- function( # nolint target, value = NULL, @@ -156,6 +161,7 @@ store_item_impl.drake_static_storage <- function( # nolint ) } +#' @export store_item_impl.drake_function <- function(target, value, meta, config) { # nolint if (meta$imported) { value <- standardize_imported_function(value) @@ -180,10 +186,12 @@ standardize_deparsed_function <- function(str) { gsub("", "", str) } +#' @export store_item_impl.drake_storr <- function(target, value, meta, config) { store_object(target, value = "storr", meta, config) } +#' @export store_item_impl.drake_object <- function(target, value, meta, config) { store_object(target, value, meta, config) } @@ -256,6 +264,7 @@ decorate_format_meta <- function(value, target, meta, config) { UseMethod("decorate_format_meta") } +#' @export decorate_format_meta.drake_format_file <- function( # nolint value, target, @@ -270,6 +279,7 @@ decorate_format_meta.drake_format_file <- function( # nolint meta } +#' @export decorate_format_meta.default <- function(value, target, meta, config) { meta } @@ -305,6 +315,7 @@ dynamic_hashes <- function(value, size, config) { UseMethod("dynamic_hashes") } +#' @export dynamic_hashes.drake_dynamic <- function(value, size, config) { vapply( seq_len(size), @@ -316,6 +327,7 @@ dynamic_hashes.drake_dynamic <- function(value, size, config) { ) } +#' @export dynamic_hashes.default <- function(value, size, config) { vapply( seq_len(size), diff --git a/R/transform_plan.R b/R/transform_plan.R index 737667f61..4a48a85bc 100644 --- a/R/transform_plan.R +++ b/R/transform_plan.R @@ -560,12 +560,15 @@ parse_transform <- function(transform, target) { ) } -assert_good_transform <- function(transform, target) UseMethod("assert_good_transform") +assert_good_transform <- function(transform, target) + UseMethod("assert_good_transform") +#' @export assert_good_transform.map <- assert_good_transform.cross <- assert_good_transform.combine <- function(transform, target) NULL +#' @export assert_good_transform.default <- function(transform, target) { stop0( "invalid transform: ", lang(transform), @@ -575,6 +578,7 @@ assert_good_transform.default <- function(transform, target) { interpret_transform <- function(transform) UseMethod("interpret_transform") +#' @export interpret_transform.map <- function(transform) { structure( transform, @@ -582,8 +586,10 @@ interpret_transform.map <- function(transform) { ) } +#' @export interpret_transform.cross <- interpret_transform.map +#' @export interpret_transform.combine <- function(transform) { structure( transform, @@ -636,6 +642,7 @@ dsl_transform <- function( UseMethod("dsl_transform") } +#' @export dsl_transform.map <- dsl_transform.cross <- function( transform, target, @@ -776,6 +783,7 @@ seq_max_expand <- function(n, max_expand) { unique(i) } +#' @export dsl_transform.combine <- function(transform, target, row, plan, graph, ...) { plan <- valid_splitting_plan(plan, transform) if (!nrow(plan)) { @@ -1035,6 +1043,7 @@ dsl_combine_join_plan <- function(plan, transform, old_cols) { dsl_deps <- function(transform) UseMethod("dsl_deps") +#' @export dsl_deps.map <- function(transform) { attr(transform, "deps") %|||% c( as.character(unnamed(as.list(transform[[1]][-1]))), @@ -1042,8 +1051,10 @@ dsl_deps.map <- function(transform) { ) } +#' @export dsl_deps.cross <- dsl_deps.map +#' @export dsl_deps.combine <- function(transform) { attr(transform, "deps") %|||% c( dsl_combine(transform), @@ -1053,6 +1064,7 @@ dsl_deps.combine <- function(transform) { dsl_revdeps <- function(transform) UseMethod("dsl_revdeps") +#' @export dsl_revdeps.map <- function(transform) { attr(transform, "revdeps") %|||% c( names(new_groupings(transform)), @@ -1061,8 +1073,10 @@ dsl_revdeps.map <- function(transform) { ) } +#' @export dsl_revdeps.cross <- dsl_revdeps.map +#' @export dsl_revdeps.combine <- function(transform) { attr(transform, "revdeps") %|||% c( tag_in(transform), @@ -1072,6 +1086,7 @@ dsl_revdeps.combine <- function(transform) { dsl_grid <- function(transform, groupings) UseMethod("dsl_grid") +#' @export dsl_grid.map <- function(transform, groupings) { tryCatch( as.data.frame(groupings, stringsAsFactors = FALSE), @@ -1091,6 +1106,7 @@ map_grid_error <- function(transform, groupings) { ) } +#' @export dsl_grid.cross <- function(transform, groupings) { do.call(expand.grid, c(groupings, stringsAsFactors = FALSE)) } @@ -1099,14 +1115,17 @@ groupings <- function(transform) { UseMethod("groupings") } +#' @export groupings.map <- groupings.cross <- function(transform) { c(new_groupings(transform), old_groupings(transform)) } +#' @export groupings.combine <- function(transform) character(0) old_groupings <- function(transform, plan = NULL) UseMethod("old_groupings") +#' @export old_groupings.map <- old_groupings.cross <- function(transform, plan = NULL) { attr(transform, "old_groupings") %|||% find_old_groupings(transform, plan) @@ -1119,6 +1138,7 @@ set_old_groupings <- function(transform, plan) { find_old_groupings <- function(transform, plan) UseMethod("find_old_groupings") +#' @export find_old_groupings.map <- function(transform, plan) { group_names <- as.character(unnamed(lang(transform))[-1]) group_names <- intersect(group_names, names(plan)) @@ -1160,6 +1180,7 @@ column_components <- function(x) { ) } +#' @export find_old_groupings.cross <- function(transform, plan) { group_names <- as.character(unnamed(lang(transform))[-1]) group_names <- intersect(group_names, names(plan)) @@ -1172,10 +1193,12 @@ na_omit <- function(x) { x[!is.na(x)] } +#' @export find_old_groupings.combine <- function(transform, plan) NULL new_groupings <- function(transform) UseMethod("new_groupings") +#' @export new_groupings.map <- function(transform) { attr <- attr(transform, "new_groupings") if (!is.null(attr)) { @@ -1202,6 +1225,7 @@ data_arg_groupings <- function(data_arg) { dsl_all_special <- c(".id", ".names", ".tag_in", ".tag_out") +#' @export new_groupings.cross <- new_groupings.map explicit_new_groupings <- function(code, exclude = character(0)) { @@ -1224,6 +1248,7 @@ long_deparse <- function(x, collapse = "\n") { dsl_combine <- function(transform) UseMethod("dsl_combine") +#' @export dsl_combine.combine <- function(transform) { attr(transform, "combine") %|||% as.character(unnamed(lang(transform))[-1]) @@ -1231,6 +1256,7 @@ dsl_combine.combine <- function(transform) { dsl_by <- function(transform) UseMethod("dsl_by") +#' @export dsl_by.combine <- function(transform) { attr(transform, "by") %|||% all.vars(lang(transform)[[".by"]], functions = FALSE) @@ -1238,6 +1264,7 @@ dsl_by.combine <- function(transform) { dsl_id <- function(transform) UseMethod("dsl_id") +#' @export dsl_id.transform <- function(transform) { if (!is.null(attr(transform, "id"))) { return(attr(transform, "id")) @@ -1251,6 +1278,7 @@ dsl_id.transform <- function(transform) { dsl_names <- function(transform) UseMethod("dsl_names") +#' @export dsl_names.transform <- function(transform) { if (!is.null(attr(transform, ".names"))) { return(attr(transform, ".names")) @@ -1260,6 +1288,7 @@ dsl_names.transform <- function(transform) { tag_in <- function(transform) UseMethod("tag_in") +#' @export tag_in.transform <- function(transform) { attr(transform, "tag_in") %|||% all.vars(lang(transform)[[".tag_in"]], functions = FALSE) @@ -1267,6 +1296,7 @@ tag_in.transform <- function(transform) { tag_out <- function(transform) UseMethod("tag_out") +#' @export tag_out.transform <- function(transform) { attr(transform, "tag_out") %|||% all.vars(lang(transform)[[".tag_out"]], functions = FALSE) @@ -1274,10 +1304,12 @@ tag_out.transform <- function(transform) { lang <- function(x) UseMethod("lang") +#' @export lang.command <- lang.transform <- function(x) x[[1]] char <- function(x) UseMethod("char") +#' @export char.transform <- function(x) safe_deparse(lang(x), backtick = TRUE) named <- function(x, exclude = character(0)) { diff --git a/man/drake-package.Rd b/man/drake-package.Rd index 9684e3388..9220c06e7 100644 --- a/man/drake-package.Rd +++ b/man/drake-package.Rd @@ -1,6 +1,5 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/package.R -\docType{package} \name{drake-package} \alias{drake-package} \alias{drake} diff --git a/man/drake_config.Rd b/man/drake_config.Rd index 10f4a1799..6cfedb8e3 100644 --- a/man/drake_config.Rd +++ b/man/drake_config.Rd @@ -52,7 +52,7 @@ drake_config( memory_strategy = "speed", spec = NULL, layout = NULL, - lock_envir = TRUE, + lock_envir = NULL, history = TRUE, recover = FALSE, recoverable = TRUE, @@ -418,15 +418,8 @@ Also see the \code{garbage_collection} argument of \code{make()} and \item{layout}{Deprecated.} -\item{lock_envir}{Logical, whether to lock \code{config$envir} during \code{make()}. -If \code{TRUE}, \code{make()} quits in error whenever a command in your -\code{drake} plan (or \code{prework}) tries to add, remove, or modify -non-hidden variables in your environment/workspace/R session. -This is extremely important for ensuring the purity of your functions -and the reproducibility/credibility/trust you can place in your project. -\code{lock_envir} will be set to a default of \code{TRUE} in \code{drake} version -7.0.0 and higher. Namespaces are never locked, e.g. -if \code{envir} is \code{getNamespace("packagename")}.} +\item{lock_envir}{Deprecated in \verb{drake >= 7.13.10}. Environments +are no longer locked.} \item{history}{Logical, whether to record the build history of your targets. You can also supply a diff --git a/man/make.Rd b/man/make.Rd index 96fe82d65..2a293260f 100644 --- a/man/make.Rd +++ b/man/make.Rd @@ -421,15 +421,8 @@ Also see the \code{garbage_collection} argument of \code{make()} and \item{spec}{Deprecated.} -\item{lock_envir}{Logical, whether to lock \code{config$envir} during \code{make()}. -If \code{TRUE}, \code{make()} quits in error whenever a command in your -\code{drake} plan (or \code{prework}) tries to add, remove, or modify -non-hidden variables in your environment/workspace/R session. -This is extremely important for ensuring the purity of your functions -and the reproducibility/credibility/trust you can place in your project. -\code{lock_envir} will be set to a default of \code{TRUE} in \code{drake} version -7.0.0 and higher. Namespaces are never locked, e.g. -if \code{envir} is \code{getNamespace("packagename")}.} +\item{lock_envir}{Deprecated in \verb{drake >= 7.13.10}. Environments +are no longer locked.} \item{history}{Logical, whether to record the build history of your targets. You can also supply a diff --git a/man/new_drake_settings.Rd b/man/new_drake_settings.Rd index 04e80f2d6..2b4437bde 100644 --- a/man/new_drake_settings.Rd +++ b/man/new_drake_settings.Rd @@ -111,15 +111,8 @@ it may duplicate the loading of dependencies, costing time.} Same as in \code{library()} or \code{require()}. Applies to the \code{packages} argument (see above).} -\item{lock_envir}{Logical, whether to lock \code{config$envir} during \code{make()}. -If \code{TRUE}, \code{make()} quits in error whenever a command in your -\code{drake} plan (or \code{prework}) tries to add, remove, or modify -non-hidden variables in your environment/workspace/R session. -This is extremely important for ensuring the purity of your functions -and the reproducibility/credibility/trust you can place in your project. -\code{lock_envir} will be set to a default of \code{TRUE} in \code{drake} version -7.0.0 and higher. Namespaces are never locked, e.g. -if \code{envir} is \code{getNamespace("packagename")}.} +\item{lock_envir}{Deprecated in \verb{drake >= 7.13.10}. Environments +are no longer locked.} \item{lock_cache}{Logical, whether to lock the cache before running \code{make()} etc. It is usually recommended to keep cache locking on. diff --git a/src/unlock_environment.c b/src/unlock_environment.c deleted file mode 100644 index cacd08e68..000000000 --- a/src/unlock_environment.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Adapted from: - * https://gist.github.com/wch/3280369#file-unlockenvironment-r and - * https://github.com/SurajGupta/r-source/blob/master/src/main/envir.c - */ - -#include -#include -#include -#include - -#ifndef FRAME_LOCK_MASK -#define FRAME_LOCK_MASK (1<<14) -#endif - -#ifndef FRAME_IS_LOCKED -#define FRAME_IS_LOCKED(e) (ENVFLAGS(e) & FRAME_LOCK_MASK) -#endif - -#ifndef UNLOCK_FRAME -#define UNLOCK_FRAME(e) SET_ENVFLAGS(e, ENVFLAGS(e) & (~ FRAME_LOCK_MASK)) -#endif - -SEXP unlock_environment(SEXP envir) { - UNLOCK_FRAME(envir); - return R_NilValue; -} - -static const R_CallMethodDef call_methods[] = { - {"Cunlock_environment", (DL_FUNC) &unlock_environment, 1}, - {NULL, NULL, 0} -}; - -void R_init_drake(DllInfo *dll) { - R_registerRoutines(dll, NULL, call_methods, NULL, NULL); - #if defined(R_VERSION) && R_VERSION >= R_Version(3, 4, 0) - R_useDynamicSymbols(dll, FALSE); - R_forceSymbols(dll, TRUE); - #endif -}