Skip to content

Commit be4a9ea

Browse files
committed
fix bug in pull_model
1 parent df5a995 commit be4a9ea

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

R/lib.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,13 @@ pgrs <- function(resp) {
261261
}
262262

263263
if (!isTRUE(the$str_prgs$pb == the$str_prgs$f)) {
264-
# format outside glue statement to get rid of NOTE in R CMD check
265-
total_pretty <- prettyunits::pretty_bytes(the$str_prgs$total)
266264
cli::cli_progress_bar(
267265
name = the$str_prgs$f,
268266
type = "download",
269267
format = paste0(
270268
"{cli::pb_spin} downloading {str_prgs$f} ",
271-
"({str_prgs$done_pct} of {total_pretty)}) ",
272-
"at {prettyunits::pretty_bytes(str_prgs$speed}/s"
269+
"({str_prgs$done_pct} of {prettyunits::pretty_bytes(str_prgs$total)}) ",
270+
"at {prettyunits::pretty_bytes(str_prgs$speed)}/s"
273271
),
274272
format_done = paste0(
275273
"{cli::col_green(cli::symbol$tick)} downloaded {str_prgs$f}"

R/models.r

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ pull_model <- function(model = NULL,
5757
} else {
5858
httr2::req_perform(req)
5959
}
60-
cli::cli_alert_success("model {model} pulled succesfully")
60+
total <- try(as.integer(the$str_prgs$total), silent = TRUE)
61+
if (methods::is(total, "try-error")) {
62+
cli::cli_alert_success("model {model} pulled succesfully")
63+
} else {
64+
total <- prettyunits::pretty_bytes(total)
65+
cli::cli_alert_success("model {model} ({total}) pulled succesfully")
66+
}
6167
the$str_prgs <- NULL
6268

6369
invisible(show_model(model))

0 commit comments

Comments
 (0)