progress
progress copied to clipboard
progressbar with the doMC package?
Is the progress package also suitable for the doMC package?
Or the parallel package? If not, +1 for this feature.
I am not sure what it would take to implement this, to be honest. E.g. for parallel, one would need parallel to communicate back, how much of the work has been done already. Is that even possible?
@gaborcsardi I did some searching and the following is what I've found:
library("foreach")
library("doParallel")
library("progress")
registerDoParallel(parallel::makeCluster(7, outfile = ""))
pb <- progress_bar$new(
format = " [:bar] :percent in :elapsed",
total = 30, clear = FALSE, width = 80, force = T)
a <- foreach (i = 1:30) %dopar% {
pb$tick()
Sys.sleep(0.5)
}
pb <- txtProgressBar(title = "Iterative training", min = 0, max = 30, style = 3)
foreach (i = 1:30) %dopar% {
setTxtProgressBar(pb, i)
Sys.sleep(0.5)
}
stopCluster(cl)
The txtProgressBar
only works when the stype is 2 or 3. According to the function's manual:
style = 1 and style = 2 just shows a line of char. They differ in that style = 2 redraws the line each time, which is useful if other code might be writing to the R console. style = 3 marks the end of the range by | and gives a percentage to the right of the bar.
I think the reason txtProgressBar
works is because the outfile = ""
exists while making the cluster.
I think mimicking what txtProgressBar
does for style 2 would solve this.
I don't know if there is any update on this, what about pbapply
package? But I find this package do more regarding the progress bar.
In general this is not possible currently, I believe. You might get lucky if the parallel processes use the same terminal as the main process, but in general we would need support from parallel to implement this.