Skip to content

Commit

Permalink
speed up verbose and timestamp reporters
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Jan 9, 2025
1 parent 9c46871 commit 1b646e3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion R/class_reporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ reporter_class <- R6::R6Class(
)
)

reporter_seconds_skipped <- 0.25
reporter_seconds_skipped <- 1
14 changes: 7 additions & 7 deletions R/class_timestamp.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ timestamp_class <- R6::R6Class(
)
},
report_skipped = function(target, progress) {
self$buffer_message(
cli_skip(
target_get_name(target),
target_get_type_cli(target),
time_stamp = TRUE,
print = FALSE
now <- time_seconds_local()
skipped <- .subset2(.subset2(progress, "skipped"), "count")
if ((now - seconds_skipped) > reporter_seconds_skipped) {
self$buffer_message(
cli_skip_many(skipped = skipped, time_stamp = TRUE, print = FALSE)
)
)
self$seconds_skipped <- now
}
},
report_errored = function(target, progress = NULL) {
self$buffer_message(
Expand Down
13 changes: 6 additions & 7 deletions R/class_verbose.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ verbose_class <- R6::R6Class(
)
},
report_skipped = function(target, progress = NULL) {
self$buffer_message(
cli_skip(
target_get_name(target),
target_get_type_cli(target),
print = FALSE
)
)
now <- time_seconds_local()
skipped <- .subset2(.subset2(progress, "skipped"), "count")
if ((now - seconds_skipped) > reporter_seconds_skipped) {
self$buffer_message(cli_skip_many(skipped = skipped, print = FALSE))
self$seconds_skipped <- now
}
},
report_errored = function(target, progress = NULL) {
self$buffer_message(
Expand Down
7 changes: 7 additions & 0 deletions R/utils_cli.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ cli_skip <- function(name, prefix = NULL, time_stamp = FALSE, print = TRUE) {
cli_green_check(msg, print = print)
}

cli_skip_many <- function(skipped, time_stamp = FALSE, print = TRUE) {
time <- if_any(time_stamp, time_stamp_cli(), NULL)
content <- sprintf("skipping targets (%s so far)...", skipped)
msg <- paste(c(time, content), collapse = " ")
cli_green_check(msg, print = print)
}

cli_error <- function(name, prefix = NULL, time_stamp = FALSE, print = TRUE) {
time <- if_any(time_stamp, time_stamp_cli(), NULL)
msg <- paste(c(time, "errored", prefix, name), collapse = " ")
Expand Down

0 comments on commit 1b646e3

Please sign in to comment.