Skip to content

Commit

Permalink
Print storage size of each target in verbose reporters
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Sep 23, 2024
1 parent 6411f1f commit 2aba17a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 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.7.1.9005
Version: 1.7.1.9006
License: MIT + file LICENSE
URL: https://docs.ropensci.org/targets/, https://github.com/ropensci/targets
BugReports: https://github.com/ropensci/targets/issues
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# targets 1.7.1.9005 (development)
# targets 1.7.1.9006 (development)

* Wrap `tar_watch()` UI module in `bslib::page()` (#1302, @kwbyron-lilly).
* Remove `callr_function` in `tar_make_as_job()` argument list.
Expand All @@ -13,6 +13,7 @@
* 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.
* Implement `error = "trim"` in `tar_target()` and `tar_option_set()` (#1310, #1311, @hadley).
* Print storage size of each target in verbose reporters (#1337, @psychelzh).

# targets 1.7.1

Expand Down
1 change: 1 addition & 0 deletions R/class_verbose.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ verbose_class <- R6::R6Class(
name = target_get_name(target),
prefix = target_get_type_cli(target),
seconds_elapsed = target$metrics$seconds,
bytes_storage = target$store$file$bytes,
print = FALSE
)
)
Expand Down
17 changes: 12 additions & 5 deletions R/utils_cli.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ cli_completed <- function(
prefix = NULL,
time_stamp = FALSE,
seconds_elapsed = NULL,
bytes_storage = NULL,
print = TRUE
) {
time <- if_any(time_stamp, time_stamp_cli(), NULL)
msg <- paste(c(time, "completed", prefix, name), collapse = " ")
if (!is.null(seconds_elapsed)) {
msg_time <- paste0(" [", units_seconds(seconds_elapsed), "]")
msg <- paste0(msg, msg_time)
message <- paste(c(time, "completed", prefix, name), collapse = " ")
metrics <- character(0L)
if (!is.null(seconds_elapsed) && !anyNA(seconds_elapsed)) {
metrics <- c(metrics, units_seconds(seconds_elapsed))
}
if (!is.null(bytes_storage) && !anyNA(bytes_storage)) {
metrics <- c(metrics, units_bytes(bytes_storage))
}
if (length(metrics)) {
metrics <- paste0("[", paste(metrics, collapse = ", "), "]")
}
cli_green_record(msg, print = print)
cli_green_record(paste(message, metrics), print = print)
}

cli_skip <- function(name, prefix = NULL, time_stamp = FALSE, print = TRUE) {
Expand Down

0 comments on commit 2aba17a

Please sign in to comment.