Skip to content

Commit

Permalink
Remove devtools::load_all() warning
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Jan 29, 2024
1 parent 62ef565 commit d889830
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 37 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Because of the changes below, upgrading to this version of `targets` will unavoidably invalidate previously built targets in existing pipelines. Your pipeline code should still work, but any targets you ran before will most likely need to rerun after the upgrade.

* In `tar_seed_create()`, use `secretbase::sha3(x = TARGET_NAME, bits = 32L, convert = NA)` to generate target seeds that are more resistant to overlapping RNG streams (#1139, @shikokuchuo). The previous approach used a less rigorous combination of `digest::digest(algo = "sha512")` and `digets::digest2int()`.
* Use `.__DEVTOOLS__` instead of static code analysis to detect `pkgload::load_all()` (#1218).
* Remove `pkgload::load_all()` warning (#1218). Tried using `.__DEVTOOLS__` but it interferes with reverse dependencies.

## Other changes

Expand Down
27 changes: 0 additions & 27 deletions R/utils_assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -648,33 +648,6 @@ tar_assert_script <- function(script) {
tar_assert_not_in(vars, choices, msg)
}

tar_warn_devtools <- function() {
for (name in grep(pattern = "^package:", x = search(), value = TRUE)) {
if (name != "package:targets") {
package <- gsub(pattern = "^package:", replacement = "", x = name)
should_warn <- !is.null(getNamespace(package)$.__DEVTOOLS__) &&
!identical(Sys.getenv("TAR_WARN", unset = ""), "false")
if_any(
should_warn,
tar_warn_validate(
"Detected package {",
package,
"} loaded with pkgload::load_all() or devtools::load_all(). ",
"Functions loaded this way cannot be detected with static code ",
"analysis and cannot be loaded into parallel workers. ",
"Please explicitly install the package, and if appropriate, ",
"use the 'envir' and 'imports' arguments of tar_option_set() ",
"as described at ",
"https://books.ropensci.org/targets/packages.html. ",
"This warning can be suppressed by setting ",
"Sys.setenv(TAR_WARN = \"false\") in your _targets.R file."
),
NULL
)
}
}
}

tar_assert_objects_files <- function(store) {
objects <- path_objects_dir(store)
files <- list.files(
Expand Down
1 change: 0 additions & 1 deletion R/utils_callr.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ tar_callr_inner_try <- function(
envir <- if_any(is.null(envir), parent, envir)
tar_options$set_envir(envir = envir)
targets <- eval(parse(file = script, keep.source = TRUE), envir = envir)
tar_warn_devtools()
targets_arguments$pipeline <- pipeline_from_list(targets)
pipeline_validate_lite(targets_arguments$pipeline)
do.call(targets_function, targets_arguments)
Expand Down
8 changes: 0 additions & 8 deletions tests/testthat/test-utils_assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,6 @@ tar_test("tar_assert_null()", {
)
})

tar_test("tar_warn_devtools()", {
skip_on_cran()
old <- Sys.getenv("TAR_WARN")
on.exit(Sys.setenv(TAR_WARN = old))
Sys.setenv(TAR_WARN = "false")
expect_silent(tar_warn_devtools())
})

tar_test("tar_assert_all_na()", {
skip_cran()
expect_silent(tar_assert_all_na(NA_character_))
Expand Down

0 comments on commit d889830

Please sign in to comment.