Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit fdd91d9

Browse files
authored
Implemented progress bar with verbose details (#181)
* Implemented a more detailed verbose progress bar * Fixed infix operator spacing * Added newline for 'Tasks have completed' message
1 parent 24f0cbb commit fdd91d9

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

R/jobUtilities.R

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,35 @@ waitForTasksToComplete <-
213213
totalTasks <- totalTasks + length(currentTasks$value)
214214
}
215215

216-
pb <- txtProgressBar(min = 0, max = totalTasks, style = 3)
217216
timeToTimeout <- Sys.time() + timeout
218217

219218
repeat {
220219
taskCounts <- rAzureBatch::getJobTaskCounts(jobId)
221-
setTxtProgressBar(pb, taskCounts$completed)
220+
progressBarValue <- round(taskCounts$completed / totalTasks * getOption("width"))
221+
222+
if (taskCounts$completed == totalTasks - 1) {
223+
status <- "Tasks have completed. Merging results"
224+
}
225+
else {
226+
status <- ""
227+
}
228+
229+
outputProgressBar <- sprintf("|%s%s|",
230+
strrep("=", progressBarValue),
231+
strrep(" ", getOption("width") - progressBarValue))
232+
outputTaskCount <- sprintf("%s (%s/%s)",
233+
sprintf("%.2f%%", (taskCounts$completed / totalTasks) * 100),
234+
taskCounts$completed,
235+
totalTasks)
236+
outputTaskCount <- sprintf("%s %s",
237+
outputTaskCount,
238+
strrep(" ", getOption("width") - nchar(as.character(outputTaskCount))))
239+
240+
cat('\r', sprintf("%s %s %s",
241+
outputProgressBar,
242+
outputTaskCount,
243+
status))
244+
flush.console()
222245

223246
validationFlag <-
224247
(taskCounts$validationStatus == "Validated" &&

0 commit comments

Comments
 (0)