Message ID | 20220307133620.12404-2-pkj@axis.com |
---|---|
State | New |
Headers | show |
Series | [1/3] knotty.py: Improve the message while waiting for running tasks to finish | expand |
On Mon, 2022-03-07 at 14:36 +0100, Peter Kjellerstedt wrote: > From: Peter Kjellerstedt <peter.kjellerstedt@axis.com> > > In commit 8055ec36 (knotty: Improve setscene task display) the setscene > tasks got their own line in the task output. However, the progress bar > code does not handle newlines in its widgets, so the length of the > setscene line was included when calculating how much space is available > for the progress bar of the running tasks, making it much too short. > > Instead of trying to teach the progress bar code to handle newlines, > give the setscene tasks their own progress bar. > > Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> > --- > bitbake/lib/bb/ui/knotty.py | 34 ++++++++++++++++++++++------------ > 1 file changed, 22 insertions(+), 12 deletions(-) I'd much prefer not to add yet another confusing progress bar as it will just confuse users more. The real progress to watch is the real tasks one and that will increase as setscene tasks are covered. Adding this draws the user's attention away from where they probably want to be looking. If you know otherwise, you don't need the progress bar IMO. Cheers, Richard
> -----Original Message----- > From: Richard Purdie <richard.purdie@linuxfoundation.org> > Sent: den 7 mars 2022 16:48 > To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>; bitbake- > devel@lists.openembedded.org > Subject: Re: [bitbake-devel] [PATCH 2/3] knotty.py: Give the setscene > tasks their own progress bar > > On Mon, 2022-03-07 at 14:36 +0100, Peter Kjellerstedt wrote: > > From: Peter Kjellerstedt <peter.kjellerstedt@axis.com> > > > > In commit 8055ec36 (knotty: Improve setscene task display) the setscene > > tasks got their own line in the task output. However, the progress bar > > code does not handle newlines in its widgets, so the length of the > > setscene line was included when calculating how much space is available > > for the progress bar of the running tasks, making it much too short. > > > > Instead of trying to teach the progress bar code to handle newlines, > > give the setscene tasks their own progress bar. > > > > Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> > > --- > > bitbake/lib/bb/ui/knotty.py | 34 ++++++++++++++++++++++------------ > > 1 file changed, 22 insertions(+), 12 deletions(-) > > I'd much prefer not to add yet another confusing progress bar as it will > just confuse users more. The real progress to watch is the real tasks > one and that will increase as setscene tasks are covered. Hmm, my first solution was without the progress bar. However, when I realized that a progress bar could be used instead, I thought it made sense. Consider the case where you are making a build which has almost everything in the sstate cache, then the current output is less optimal. I.e., the first line will show a counter increasing, but no progress bar, while the second line shows a progress bar that basically goes from 0% to 100% in one step once all the setscene tasks are done. > Adding this draws the user's attention away from where they probably want > to be looking. If you know otherwise, you don't need the progress bar IMO. Need is a strong word when it comes to the progress bars. Personally I like to watch them move along. :) I find it easier to get a view of the current progress by looking at the bars rather than the corresponding numbers. > Cheers, > > Richard //Peter
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py index a520895da2..179cea43fa 100644 --- a/bitbake/lib/bb/ui/knotty.py +++ b/bitbake/lib/bb/ui/knotty.py @@ -204,6 +204,7 @@ class TerminalFilter(object): for h in handlers: h.addFilter(InteractConsoleLogFilter(self)) + self.setscene_progress = None self.main_progress = None def clearFooter(self): @@ -278,25 +279,34 @@ class TerminalFilter(object): content += ':' print(content) else: - if self.quiet: - content = "Running tasks (%s of %s, %s of %s)" % (self.helper.setscene_current, self.helper.setscene_total, self.helper.tasknumber_current, self.helper.tasknumber_total) - elif not len(activetasks): - content = "Setscene tasks: %s of %s\nNo currently running tasks (%s of %s)" % (self.helper.setscene_current, self.helper.setscene_total, self.helper.tasknumber_current, self.helper.tasknumber_total) - else: - content = "Setscene tasks: %s of %s\nCurrently %2s running tasks (%s of %s)" % (self.helper.setscene_current, self.helper.setscene_total, len(activetasks), self.helper.tasknumber_current, self.helper.tasknumber_total) + content = '' + curtask = self.helper.setscene_current + maxtask = self.helper.setscene_total + msg = "Setscene tasks (%s of %s)" % (curtask, maxtask) + if not self.setscene_progress or self.setscene_progress.maxval != maxtask: + widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()] + self.setscene_progress = BBProgress("Setscene tasks", maxtask, widgets=widgets, resize_handler=self.sigwinch_handle) + self.setscene_progress.start(False) + self.setscene_progress.setmessage(msg) + content += self.setscene_progress.update(curtask) + "\n" + print('') + + curtask = self.helper.tasknumber_current maxtask = self.helper.tasknumber_total + if not len(activetasks): + msg = "No running tasks (%s of %s)" % (curtask, maxtask) + else: + msg = "%2s running tasks (%s of %s)" % (len(activetasks), curtask, maxtask) if not self.main_progress or self.main_progress.maxval != maxtask: widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()] self.main_progress = BBProgress("Running tasks", maxtask, widgets=widgets, resize_handler=self.sigwinch_handle) self.main_progress.start(False) - self.main_progress.setmessage(content) - progress = self.helper.tasknumber_current - 1 - if progress < 0: - progress = 0 - content = self.main_progress.update(progress) + self.main_progress.setmessage(msg) + progress = max(0, curtask - 1) + content += self.main_progress.update(progress) print('') lines = self.getlines(content) - if self.quiet == 0: + if not self.quiet: for tasknum, task in enumerate(tasks[:(self.rows - 1 - lines)]): if isinstance(task, tuple): pbar, progress, rate, start_time = task