httr2 icon indicating copy to clipboard operation
httr2 copied to clipboard

configuring progress messages

Open mkoohafkan opened this issue 1 year ago • 3 comments

it appears that there are three ways to enable/disable progress messages:

  1. req_progress() allows you to enable progress messages and specify a direction, but does not allow you to disable them.
  2. req_options(noprogress = TRUE) looks like it can disable progress messages, but it is unclear as req_options() documentation states that these are curl options, not httr2 options.
  3. req_perform_*() functions (e.g., req_perform_paralle()) have a boolean progress argument.

It is unclear how these options interact. It appears that req_progress() is just a wrapper around req_options(noprogress = FALSE), but the documentation specifies that req_options() is for configuring curl options rather than httr2 options. It also appears that the progress argument to the multi-request functions req_perform_*() is a separate progress bar for the request batch, and unrelated to the progress bar for individual requests (so you could end up with nested progress bars, or disable the progress for the request batch but not the individual requests, or vice versa).

I have two suggestions:

  1. Add support req_progress(type = "none") so that request progress can be enabled/disabled from a single entry point, rather than requiring req_options() to disable and req_progress() to enable.
  2. Clarify the documentation on the progress argument to multiple request functions to differentiate it from req_progress().

mkoohafkan avatar Mar 13 '24 18:03 mkoohafkan

Why do you want to disable the progress bar? (Rather than just failing to enable it?)

I'm a bit leery of adding a way to turn it off because I think that would imply the need for a bunch of other tools to suppress the actions that other req_ functions have taken.

hadley avatar Mar 13 '24 19:03 hadley

If the default is always for no progress messages then (1) is not needed. I was getting intermittent test errors because messages were occasionally being thrown, but on further inspection this may have been the parallel/iterative progress message rather than the request progress message. Note that req_perform_*() functions have progress = TRUE by default.

mkoohafkan avatar Mar 13 '24 22:03 mkoohafkan

Hmmmm, we should probably suppress those by default in tests, since it's a bit easier for do it centrally in httr2 rather than in every package that wraps it.

I'll also clarify the difference in the progress bars to the docs: req_progress() adds a progress bar for the download of an individual request; the progress argument to req_perform_parallel() and friends gives the progress across all requests. I should also note that you can't use them together.

hadley avatar Mar 14 '24 12:03 hadley