From 92b2baa82cbacb2ba5abd459e58eadadf1b70e71 Mon Sep 17 00:00:00 2001 From: wlandau-lilly Date: Fri, 2 Mar 2018 13:27:14 -0500 Subject: [PATCH] Use tibbles for build times... ...now that pillar 1.2.1 is out. Rleated: #247. --- R/build_times.R | 5 ++++- R/handlers.R | 8 ++++++++ R/predict_runtime.R | 9 +++++++-- tests/testthat/test-edge-cases.R | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/R/build_times.R b/R/build_times.R index 0dcb25510..294daffe0 100644 --- a/R/build_times.R +++ b/R/build_times.R @@ -72,7 +72,10 @@ build_times <- function( if (targets_only){ out <- out[out$type == "target", ] } - out + tryCatch( + as_tibble(out), + error = error_tibble_times + ) } fetch_runtime <- function(key, cache, type){ diff --git a/R/handlers.R b/R/handlers.R index 3b2711835..0302cded8 100644 --- a/R/handlers.R +++ b/R/handlers.R @@ -47,3 +47,11 @@ error_na <- function(e){ error_null <- function(e){ NULL } + +error_tibble_times <- function(e){ + stop( + "Failed converting a data frame of times to a tibble. ", + "Please install version 1.2.1 or greater of the pillar package.", + call. = FALSE + ) +} diff --git a/R/predict_runtime.R b/R/predict_runtime.R index 5736b3f8b..c79400859 100644 --- a/R/predict_runtime.R +++ b/R/predict_runtime.R @@ -184,7 +184,8 @@ rate_limiting_times <- function( digits = Inf, targets_only = FALSE, verbose = TRUE - ) + ) %>% + as.data.frame keys <- V(config$graph)$name import_keys <- setdiff(keys, config$plan$target) items <- intersect(keys, times$item) @@ -213,7 +214,11 @@ rate_limiting_times <- function( ) %>% round_times(digits = digits) %>% unname_rows - out[!is.na(out$item), ] + out <- out[!is.na(out$item), ] + tryCatch( + as_tibble(out), + error = error_tibble_times + ) } append_stages_to_times <- function(x, config){ diff --git a/tests/testthat/test-edge-cases.R b/tests/testthat/test-edge-cases.R index a5adb42c9..c11656ae2 100644 --- a/tests/testthat/test-edge-cases.R +++ b/tests/testthat/test-edge-cases.R @@ -92,6 +92,7 @@ test_with_dir("error handlers", { expect_false(error_false(1)) expect_equal(error_character0(1), character(0)) expect_null(error_null(1)) + expect_error(error_tibble_times(123)) }) test_with_dir("error when file target names do not match actual filenames", {