Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in progress (documentation) #557

Open
JBGruber opened this issue Oct 3, 2024 · 0 comments
Open

Issue in progress (documentation) #557

JBGruber opened this issue Oct 3, 2024 · 0 comments

Comments

@JBGruber
Copy link

JBGruber commented Oct 3, 2024

I looks like the documentation of ?httr2::progress_bars is wrong:

httr2/R/progress-bars.R

Lines 33 to 35 in 5380f21

#' * `show_after`: numeric scalar. Only show the progress bar after this
#' number of seconds. It overrides the `cli.progress_show_after`
#' global option.

Here is a reproducible example:

library(httr2)
req <- request(example_url()) |> 
  req_url_path("/delay/0.5")

reqs <- rep(list(req), 15)

pb_config <- list(
  show_after = 0
)

resps <- httr2::req_perform_parallel(
  reqs = reqs,
  on_error = "continue",
  progress = pb_config
)

It fails with:

Error in (function (name = NULL, status = NULL, type = c("iterator", "tasks",  : 
  unused argument (show_after = 0)

I tried to track down where the progress is handed to cli and I think that's here for the case of a named list:

httr2/R/utils.R

Line 278 in 5380f21

id <- exec(cli::cli_progress_bar, !!!args)

However, cli::cli_progress_bar lost the show_after parameter a while ago.

A workaround would be to set cli.progress_show_after temporarily:

req_perform_parallel2 <- function(..., progress) {
  show_after <- progress$show_after
  progress$show_after <- NULL
  resps <- withr::with_options(
    list(cli.progress_show_after = show_after), 
    httr2::req_perform_parallel(..., progress = progress)
  )
}

resps <- req_perform_parallel2(
  reqs = reqs,
  on_error = "continue",
  progress = pb_config
)

Happy to make a PR either fixing the documentation or the function with the workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant