Skip to content

Commit

Permalink
Fix #1312
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Aug 1, 2024
1 parent cfa4159 commit 3c850ab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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, <doi:10.21105/joss.00550>).
Version: 1.7.1.9004
Version: 1.7.1.9005
License: MIT + file LICENSE
URL: https://docs.ropensci.org/targets/, https://github.com/ropensci/targets
BugReports: https://github.com/ropensci/targets/issues
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# targets 1.7.1.9004 (development)
# targets 1.7.1.9005 (development)

* Wrap `tar_watch()` UI module in `bslib::page()` (#1302, @kwbyron-lilly).
* Remove `callr_function` in `tar_make_as_job()` argument list.
* Ensure `storage = "worker"` is respected when the process of storing an object generates an error (#1304, @multimeric).
* Default to the `_targets.R` pattern in `tar_branches()` (#1306, @multimeric, @mattwarkentin).
* Remove superfluous functions and globals from metadata with `tar_prune()` (#1312, @benzipperer).

# targets 1.7.1

Expand Down
2 changes: 1 addition & 1 deletion R/tar_prune.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ tar_prune_inner <- function(pipeline, cloud, path_store, batch_size, verbose) {
names <- pipeline_get_names(pipeline)
meta <- meta_init(path_store = path_store)
data <- as.data.frame(meta$database$read_condensed_data())
imports <- data$name[data$type %in% c("function", "object")]
imports <- names(pipeline$imports)
children <- unlist(data$children[data$name %in% names])
children <- unique(children[!is.na(children)])
keep <- c(names, children, imports)
Expand Down
15 changes: 11 additions & 4 deletions tests/testthat/test-tar_prune.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,26 @@ tar_test("tar_prune() works with patterns", {
expect_true(all(grepl("^y_|^x", names)))
})

tar_test("tar_prune() does not remove global objects from metadata", {
tar_test("tar_prune() removes old global objects from metadata", {
skip_cran()
envir <- new.env(parent = baseenv())
envir$a <- 1L
envir$f <- identity
envir$g <- identity
tar_option_set(envir = envir)
x <- target_init("x", quote(f(a)))
x <- target_init("x", quote(f(g(a))))
pipeline <- pipeline_init(list(x))
local_init(pipeline = pipeline)$run()
tar_script(list(tar_target(x, quote(1))))
names <- meta_init()$database$read_data()$name
expect_equal(sort(names), sort(c("a", "f", "g", "x")))
tar_script({
a <- 1L
g <- identity
list(tar_target(x, quote(g(a))))
})
tar_prune(callr_arguments = list(show = FALSE))
names <- meta_init()$database$read_data()$name
expect_equal(sort(names), sort(c("a", "f", "x")))
expect_equal(sort(names), sort(c("a", "g", "x")))
})

tar_test("tar_delete() does not delete dynamic files", {
Expand Down

0 comments on commit 3c850ab

Please sign in to comment.