Skip to content

Commit

Permalink
Fix #918
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Jun 23, 2019
1 parent 3a4ebcd commit 505884f
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 48 deletions.
64 changes: 33 additions & 31 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -89,37 +89,39 @@ Imports:
storr (>= 1.1.0),
utils
Suggests:
abind,
bindr,
callr,
cli (>= 1.1.0),
clustermq (>= 0.8.8),
crayon,
curl (>= 2.7),
datasets,
downloader,
future,
ggplot2,
ggraph,
grDevices,
knitr,
lubridate,
networkD3,
parallel,
prettycode,
Rcpp,
rmarkdown,
rstudioapi,
stats,
styler,
testthat (>= 2.1.0),
tibble,
tidyselect (>= 0.2.4),
txtq (>= 0.1.2),
txtplot,
usethis,
visNetwork,
webshot
abind,
bindr,
callr,
cli (>= 1.1.0),
clustermq (>= 0.8.8),
crayon,
curl (>= 2.7),
datasets,
downloader,
future,
ggplot2,
ggraph,
grDevices,
knitr,
lubridate,
networkD3,
parallel,
prettycode,
Rcpp,
rmarkdown,
rstudioapi,
stats,
styler,
testthat (>= 2.1.0),
tibble,
tidyselect (>= 0.2.4),
txtq (>= 0.1.3),
txtplot,
usethis,
visNetwork,
webshot
Remotes:
wlandau/txtq
VignetteBuilder: knitr
Encoding: UTF-8
Language: en-US
Expand Down
7 changes: 3 additions & 4 deletions R/api-history.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#' d$x2 <- d$x ^ 3
#' lm(y ~ x2, data = d)
#' }
#' Sys.sleep(1.1)
#' Sys.sleep(0.01)
#' make(my_plan, history = TRUE, verbose = 0L)
#' # The history is a data frame about all the recorded runs of your targets.
#' out <- drake_history(analyze = TRUE)
Expand Down Expand Up @@ -88,9 +88,8 @@ drake_history <- function(
command = out$command,
runtime = out$runtime
)
ref <- as.POSIXct("0000-01-01", origin = "0000-01-01")
out <- out[order(out$target, ref - out$time), ]
out$latest <- !duplicated(out$target)
out <- out[order(out$target, out$time), ]
out$latest <- !duplicated(out$target, fromLast = TRUE)
if (analyze) {
args <- lapply(out$command, find_args)
args <- do.call(drake_bind_rows, args)
Expand Down
4 changes: 2 additions & 2 deletions R/utils-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,6 @@ make_unique <- function(x) {
y[order(ord)]
}

microtimestamp <- function() {
format(Sys.time(), "%Y-%m-%d %H:%M:%OS9")
microtime <- function() {
format(Sys.time(), "%Y-%m-%d %H:%M:%OS9 %z GMT")
}
2 changes: 1 addition & 1 deletion R/vis-console.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ drake_log <- function(..., target = character(0), config) {
"|",
Sys.getpid(),
"|",
microtimestamp(),
microtime(),
"|",
target,
"|",
Expand Down
35 changes: 27 additions & 8 deletions man/drake_history.Rd

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

19 changes: 17 additions & 2 deletions tests/testthat/test-history.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ test_with_dir("history with no cache", {
})

test_with_dir("basic history", {
skip_on_cran()
skip_if_not_installed("txtq")
# Iterate.
load_mtcars_example()
Expand All @@ -15,7 +14,7 @@ test_with_dir("basic history", {
d$x2 <- d$x ^ 3
lm(y ~ x2, data = d)
}
Sys.sleep(1.1)
Sys.sleep(0.01)
make(my_plan, history = TRUE, cache = cache, session_info = FALSE)

# Get and inspect the history.
Expand Down Expand Up @@ -59,3 +58,19 @@ test_with_dir("basic history", {
expect_na <- out$target == "small" | !out$latest
expect_equal(is.na(out$hash), expect_na)
})

test_with_dir("complicated history commands", {
skip_if_not_installed("txtq")
plan <- drake_plan(
a = identity(
x = list(a = "x", 2, b = list(y = 3L, z = sqrt(4), w = "5"))
)
)
cache <- storr::storr_environment()
make(plan, cache = cache, session_info = FALSE, history = TRUE)
out <- drake_history(cache = cache, analyze = TRUE)
expect_equal(ncol(out), 10L)
expect_equal(out$a, "x")
expect_equal(out$w, "5")
expect_equal(out$y, 3L)
})

1 comment on commit 505884f

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/api-history.R:41:6: style: Commented code should be removed.

#' # View(out)
     ^~~~~~~~~

Please sign in to comment.