Skip to content

Commit

Permalink
Fix ##1429
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Feb 10, 2025
1 parent 4e70579 commit 96e0487
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 4 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.10.1.9003
Version: 1.10.1.9004
License: MIT + file LICENSE
URL: https://docs.ropensci.org/targets/, https://github.com/ropensci/targets
BugReports: https://github.com/ropensci/targets/issues
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ S3method(store_read_object,tar_gcp)
S3method(store_read_object,tar_gcp_file)
S3method(store_read_object,tar_repository_cas)
S3method(store_read_object,tar_repository_cas_file)
S3method(store_read_path,tar_auto)
S3method(store_read_path,tar_feather)
S3method(store_read_path,tar_fst)
S3method(store_read_path,tar_fst_dt)
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# targets 1.10.1.9003 (development)
# targets 1.10.1.9004 (development)

* Upload workspaces to the cloud if `tar_option_get("repository_meta")` is `"aws"` or `"gcp"`. Download them with `tar_workspace_download()` and delete them with `tar_destroy(destroy = "all")` or `tar_destroy(destroy = "cloud")`.
* Deep-copy settings when resolving `format = "auto"` (#1425, @paulseamer).
* Add `store_read_path.tar_auto()` (#1429, @paulseamer).

# targets 1.10.1

Expand Down
12 changes: 11 additions & 1 deletion R/class_auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ store_assert_format_setting.auto <- function(format) {

#' @export
store_get_packages.tar_auto <- function(store) {
"qs"
"qs2"
}

#' @export
Expand Down Expand Up @@ -53,3 +53,13 @@ store_reformat_auto <- function(target) {
)
target_reformat(target, format)
}

#' @export
store_read_path.tar_auto <- function(store, path) {
path_qs <- path_objects(.subset2(tar_runtime, "store"), basename(path))
if_any(
identical(path, path_qs),
store_read_path.tar_qs(store = store, path = path),
store_read_path.tar_store_file(store = store, path = path)
)
}
2 changes: 2 additions & 0 deletions R/tar_target.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#'
#' NOTE: `format = "auto"` slows down pipelines with 10000+ targets
#' because it creates deep copies of 20000+ internal data objects.
#' Pipelines of this size should use a more explicit format instead of
#' `"auto"`.
#' * `"qs"`: Uses `qs2::qs_save()` and `qs2::qs_read()`. Should work for
#' most objects, much faster than `"rds"`. Optionally configure settings
#' through `tar_resources()` and `tar_resources_qs()`.
Expand Down
2 changes: 2 additions & 0 deletions man/tar_option_set.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/tar_target.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion tests/testthat/test-class_auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ tar_test("auto format with error null", {
})

tar_test("store_get_packages.tar_auto()", {
expect_equal(store_get_packages.tar_auto(list()), "qs")
expect_equal(store_get_packages.tar_auto(list()), "qs2")
})

tar_test("store_reformat_auto()", {
Expand Down Expand Up @@ -72,3 +72,24 @@ tar_test("store_path_from_name() file", {
)
expect_equal(out, path_objects(path_store_default(), "x"))
})

tar_test("store_read_path.tar_auto()", {
skip_cran()
write.csv(data.frame(x = 1), "a.csv")
write.csv(data.frame(x = 2), "b.csv")
tar_script({
list(
tar_target(input, c("a.csv", "b.csv"), format = "rds"),
tar_target(paths, input, pattern = map(input), format = "file"),
tar_target(
data,
read.csv(paths),
pattern = map(paths),
format = "auto"
),
tar_target(new_data, data, format = "auto")
)
})
tar_make(callr_function = NULL)
expect_true(is.data.frame(tar_read(new_data)))
})

0 comments on commit 96e0487

Please sign in to comment.