Skip to content

Commit

Permalink
Un-export hidden functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Nov 13, 2023
1 parent 12e6f95 commit 6a655f1
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 63 deletions.
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,6 @@ export(tar_option_reset)
export(tar_option_set)
export(tar_outdated)
export(tar_path)
export(tar_path_objects_dir)
export(tar_path_objects_dir_cloud)
export(tar_path_script)
export(tar_path_script_support)
export(tar_path_store)
Expand Down
2 changes: 1 addition & 1 deletion R/class_resources_aws.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resources_aws_init <- function(
bucket = NULL,
prefix = tar_path_objects_dir_cloud(),
prefix = path_objects_dir_cloud(),
region = NULL,
endpoint = NULL,
s3_force_path_style = NULL,
Expand Down
2 changes: 1 addition & 1 deletion R/class_resources_gcp.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resources_gcp_init <- function(
bucket = NULL,
prefix = tar_path_objects_dir_cloud(),
prefix = path_objects_dir_cloud(),
predefined_acl = "private",
max_tries = 5L,
verbose = FALSE
Expand Down
6 changes: 3 additions & 3 deletions R/class_runtime.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ runtime_validate <- function(x) {

runtime_set_file_info <- function(runtime, store) {
objects <- list.files(
path = targets::tar_path_objects_dir(store),
path = path_objects_dir(store),
all.files = TRUE,
full.names = TRUE,
no.. = TRUE
Expand All @@ -96,8 +96,8 @@ runtime_set_file_info <- function(runtime, store) {
names(file_info$size) <- objects
names(file_info$mtime_numeric) <- objects
runtime$file_info <- file_info
runtime$file_exist <- targets::tar_counter(names = objects)
runtime$file_info_exist <- targets::tar_counter(names = objects)
runtime$file_exist <- tar_counter(names = objects)
runtime$file_info_exist <- tar_counter(names = objects)
}

runtime_reset <- function(x) {
Expand Down
4 changes: 2 additions & 2 deletions R/tar_resources_aws.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ tar_resources_aws <- function(
tar_warn_prefix()
prefix <- path_store_default()
}
prefix <- prefix %|||% targets::tar_path_objects_dir_cloud()
prefix <- prefix %|||% path_objects_dir_cloud()
part_size <- part_size %|||% (5 * (2 ^ 20))
page_size <- page_size %|||% 1000L
verbose <- verbose %|||% TRUE
args <- list(...)
default_args <- targets::tar_option_get("resources")$aws$args
default_args <- tar_options$get_resources()$aws$args
for (name in names(default_args)) {
args[[name]] <- args[[name]] %|||% default_args[[name]]
}
Expand Down
19 changes: 2 additions & 17 deletions R/utils_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,15 @@ path_objects <- function(path_store, name) {
file.path(path_objects_dir(path_store), name)
}

#' @title Path to directory of saved targets
#' @export
#' @keywords internal
#' @description Internal function. Not for users.
#' @param path_store Path to the data store.
#' @examples
#' tar_path_objects_dir("_targets")
tar_path_objects_dir <- function(path_store) {
path_objects_dir <- function(path_store) {
path_objects_dir(path_store = path_store)
}

path_objects_dir <- function(path_store) {
file.path(path_store, "objects")
}

#' @title Default pseudo-directory path of target data in the cloud
#' @export
#' @keywords internal
#' @description Not a user-side function. Do not invoke directly.
#' @return Character of length,
#' default pseudo-directory path of target data in the cloud.
#' @examples
#' tar_path_objects_dir_cloud()
tar_path_objects_dir_cloud <- function() {
path_objects_dir_cloud <- function() {
file.path(path_store_default(), "objects", fsep = "/")
}

Expand Down
18 changes: 0 additions & 18 deletions man/tar_path_objects_dir.Rd

This file was deleted.

19 changes: 0 additions & 19 deletions man/tar_path_objects_dir_cloud.Rd

This file was deleted.

37 changes: 37 additions & 0 deletions tests/testthat/test-class_runtime.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,43 @@ tar_test("validate non-null store", {
expect_silent(runtime_validate(x))
})

tar_test("runtime reset", {
x <- runtime_new()
x$store <- "store"
x$script <- "script"
expect_equal(x$store, "store")
expect_equal(x$script, "script")
runtime_reset(x)
expect_null(x$store)
expect_null(x$script)
})

tar_test("runtime_set_file_info()", {
x <- runtime_new()
store <- path_store_default()
dir_create(path_objects_dir(store))
writeLines("x", path_objects(store, "x"))
writeLines("y", path_objects(store, "y"))
runtime_set_file_info(x, store)
for (field in c("size", "mtime_numeric")) {
expect_true(is.numeric(x$file_info[[field]]))
expect_equal(
sort(names(x$file_info[[field]])),
sort(c(path_objects(store, "x"), path_objects(store, "y")))
)
}
for (field in c("file_exist", "file_info_exist")) {
expect_true(is.environment(x[[field]]))
expect_silent(counter_validate(x[[field]]))
expect_equal(x[[field]]$count, 2L)
expect_equal(as.logical(as.list(x[[field]]$envir)), c(TRUE, TRUE))
expect_equal(
sort(names(as.list(x[[field]]$envir))),
sort(c(path_objects(store, "x"), path_objects(store, "y")))
)
}
})

tar_test("detect bad store", {
x <- runtime_new()
x$store <- FALSE
Expand Down

0 comments on commit 6a655f1

Please sign in to comment.