Skip to content

Commit

Permalink
CRAN patch 3
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed May 23, 2023
1 parent 144b1bb commit eb94a95
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 14 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.1.2.9000
Version: 1.1.3
License: MIT + file LICENSE
URL: https://docs.ropensci.org/targets/, https://github.com/ropensci/targets
BugReports: https://github.com/ropensci/targets/issues
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# targets 1.1.2.9000

# targets 1.1.3

* Decide on `nanonext` usage in `time_seconds_local()` at runtime and not installation time. That way, if `nanonext` is removed after `targets` is installed, functions in `targets` still work. Fixes the CRAN issues seen in `tarchetypes`, `jagstargets`, and `gittargets`.

# targets 1.1.2

Expand Down
9 changes: 7 additions & 2 deletions R/class_runtime.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ runtime_new <- function(
gcp_auth = NULL,
file_exist = NULL,
file_info = NULL,
file_info_exist = NULL
file_info_exist = NULL,
nanonext = NULL
) {
force(target)
force(frames)
Expand All @@ -22,6 +23,7 @@ runtime_new <- function(
force(file_exist)
force(file_info)
force(file_info_exist)
force(nanonext)
environment()
}

Expand Down Expand Up @@ -61,7 +63,6 @@ runtime_validate <- function(x) {
if (!is.null(x$gcp_auth)) {
tar_assert_scalar(x$gcp_auth)
tar_assert_lgl(x$gcp_auth)
tar_assert_nzchar(x$gcp_auth)
}
if (!is.null(x$file_exist)) {
tar_assert_envir(x$file_exist)
Expand All @@ -73,6 +74,10 @@ runtime_validate <- function(x) {
if (!is.null(x$file_info_exist)) {
tar_assert_envir(x$file_info_exist)
}
if (!is.null(x$nanonext)) {
tar_assert_scalar(x$nanonext)
tar_assert_lgl(x$nanonext)
}
}

#' @title Get the `tar_runtime` object.
Expand Down
16 changes: 7 additions & 9 deletions R/utils_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ time_seconds <- function() {
)
}

# not possible to cover both cases
# nocov start
if (length(find.package("nanonext", quiet = TRUE)) > 0L) {
time_seconds_local <- function() {
nanonext::mclock() / 1e3
time_seconds_local <- function() {
if (is.null(tar_runtime$nanonext)) {
tar_runtime$nanonext <- rlang::is_installed("nanonext")
}
} else {
time_seconds_local <- function() {
if_any(
tar_runtime$nanonext,
nanonext::mclock() / 1e3,
as.numeric(proc.time()["elapsed"])
}
)
}
# nocov end
1 change: 1 addition & 0 deletions tests/testthat/test-class_aws.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ tar_test("deprecated aws_* classes", {
})

tar_test("package detection", {
skip_cran()
target <- tar_target(x, "x_value", format = "feather", repository = "aws")
out <- sort(store_get_packages(target$store))
exp <- sort(c("paws", "arrow"))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-class_gcp.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ tar_test("store_gcp_version()", {
})

tar_test("package detection", {
skip_cran()
target <- tar_target(x, "x_value", format = "feather", repository = "gcp")
out <- sort(store_get_packages(target$store))
exp <- sort(c("googleCloudStorageR", "arrow"))
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-class_runtime.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ tar_test("file_info_exist", {
expect_silent(runtime_validate(x))
})

tar_test("nanonext", {
x <- runtime_new()
expect_null(x$nanonext)
x$nanonext <- TRUE
expect_true(x$nanonext)
expect_silent(runtime_validate(x))
})

tar_test("validate null fields", {
x <- runtime_new()
expect_silent(runtime_validate(x))
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-utils_time.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test_that("time_seconds_local()", {
tar_runtime$nanonext <- NULL
for (i in seq_len(4)) {
out <- time_seconds_local()
expect_true(is.numeric(out))
expect_false(anyNA(out))
expect_equal(length(out), 1L)
}
expect_equal(2 * 2, 4)
})

0 comments on commit eb94a95

Please sign in to comment.