Skip to content

Commit

Permalink
tar_format_get()
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Aug 28, 2024
1 parent 71d9b17 commit d7f4228
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ export(tar_exist_process)
export(tar_exist_progress)
export(tar_exist_script)
export(tar_format)
export(tar_format_get)
export(tar_github_actions)
export(tar_glimpse)
export(tar_group)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Implement `format = "auto"` (#1311, @hadley).
* Replace `pingr` dependency with `base::socketConnection()` for local URL utilities (#1317, #1318, @Adafede).
* Implement `tar_repository_cas()`, `tar_repository_cas_local()`, and `tar_repository_cas_local_gc()` for content-addressable storage (#1232, #1314, @noamross).
* Add `tar_format_get()` to make implementing CAS systems easier.

# targets 1.7.1

Expand Down
17 changes: 17 additions & 0 deletions R/tar_format_get.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#' @title Current storage format.
#' @export
#' @family utilities
#' @description Get the storage format of the target currently running.
#' @details This function is meant to be called inside a target in a
#' running pipeline. If it is called outside a target in the running
#' pipeline, it will return the default format given by
#' `tar_option_get("format")`.
#' @return A character string, storage format of the target currently
#' running in the pipeline. If called outside a target in the running
#' pipeline, [tar_format_get()] will return the default format given by
#' `tar_option_get("format")`.
#' @examples
#' tar_target(x, tar_format_get(), format = "qs")
tar_format_get <- function() {
tar_definition()$settings$format
}
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ reference:
- 'tar_definition'
- 'tar_described_as'
- 'tar_envir'
- 'tar_format_get'
- 'tar_group'
- 'tar_name'
- 'tar_path_script'
Expand Down
1 change: 1 addition & 0 deletions man/tar_active.Rd

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

1 change: 1 addition & 0 deletions man/tar_backoff.Rd

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

1 change: 1 addition & 0 deletions man/tar_call.Rd

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

1 change: 1 addition & 0 deletions man/tar_cancel.Rd

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

1 change: 1 addition & 0 deletions man/tar_definition.Rd

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

1 change: 1 addition & 0 deletions man/tar_described_as.Rd

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

1 change: 1 addition & 0 deletions man/tar_envir.Rd

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

46 changes: 46 additions & 0 deletions man/tar_format_get.Rd

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

1 change: 1 addition & 0 deletions man/tar_group.Rd

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

1 change: 1 addition & 0 deletions man/tar_name.Rd

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

1 change: 1 addition & 0 deletions man/tar_path.Rd

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

1 change: 1 addition & 0 deletions man/tar_path_script.Rd

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

1 change: 1 addition & 0 deletions man/tar_path_script_support.Rd

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

1 change: 1 addition & 0 deletions man/tar_path_store.Rd

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

1 change: 1 addition & 0 deletions man/tar_path_target.Rd

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

1 change: 1 addition & 0 deletions man/tar_source.Rd

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

1 change: 1 addition & 0 deletions man/tar_store.Rd

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

8 changes: 8 additions & 0 deletions tests/testthat/test-tar_format_get.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tar_test("tar_format_get()", {
skip_cran()
skip_if_not_installed("qs")
expect_equal(tar_format_get(), tar_option_get("format"))
tar_script(tar_target(x, tar_format_get(), format = "qs"))
tar_make(callr_function = NULL)
expect_equal(tar_read(x), "qs")
})

0 comments on commit d7f4228

Please sign in to comment.