Skip to contentSkip to conversation

knotty.py: Improve the message while waiting for running tasks to finish

PATCH Superseded Peter Kjellerstedt 3 participants 7 messages Mar 7, 2022

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 knotty.py: Improve the message while waiting for running tasks to finish

From: Peter Kjellerstedt <[email protected]>

Use pluralise() to correct the grammar, and drop the colon at the end if runnning in quiet mode.

---
 bitbake/lib/bb/ui/knotty.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
bitbake/lib/bb/ui/knotty.py +4 -1
index b02e59c1fe..a520895da2 100644
@@ -272,7 +272,10 @@ class TerminalFilter(object):
                     tasks.append("%s (pid %s)" % (activetasks[t]["title"], activetasks[t]["pid"]))
 
         if self.main.shutdown:
-            content = "Waiting for %s running tasks to finish:" % len(activetasks)
+            content = pluralise("Waiting for %s running task to finish",
+                                "Waiting for %s running tasks to finish", len(activetasks))
+            if not self.quiet:
+                content += ':'
             print(content)
         else:
             if self.quiet:
#1 lore raw

PATCH 2/3 knotty.py: Give the setscene tasks their own progress bar

From: Peter Kjellerstedt <[email protected]>

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.

---
 bitbake/lib/bb/ui/knotty.py | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)
bitbake/lib/bb/ui/knotty.py +22 -12
index a520895da2..179cea43fa 100644
@@ -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
#2 lore raw

Re: [bitbake-devel] [PATCH 2/3] knotty.py: Give the setscene tasks their own progress bar

Quoted 8 lines · Peter Kjellerstedt

From: Peter Kjellerstedt <[email protected]>

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.

Quoted 7 lines

Instead of trying to teach the progress bar code to handle newlines, give the setscene tasks their own progress bar.

---
 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

#3 lore raw

RE: [bitbake-devel] [PATCH 2/3] knotty.py: Give the setscene tasks their own progress bar

Quoted 20 lines

-----Original Message-----
From: Richard Purdie <[email protected]>
Sent: den 7 mars 2022 16:48
To: Peter Kjellerstedt <[email protected]>; bitbake- [email protected]
Subject: Re: [bitbake-devel] [PATCH 2/3] knotty.py: Give the setscene tasks their own progress bar

Quoted 11 lines · Peter Kjellerstedt

From: Peter Kjellerstedt <[email protected]>

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.

Quoted 8 lines
Quoted 4 lines
---
 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.

Quoted 2 lines

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.

Quoted 3 lines

Cheers,

Richard

//Peter

#4 lore raw

PATCH 3/3 knotty.py: Separate the display of main tasks from running tasks

In reply to Peter Kjellerstedt

From: Peter Kjellerstedt <[email protected]>

It can be confusing that the count of running tasks shown together with the progress bar for the main tasks also includes any running setscene tasks.

Separate the display so that the message for the main tasks' progress bar only includes information on the main tasks, and the display of the count of currently running tasks gets it own line.

---

This should be considered an RFC. With this change, the progress lines for the setscene tasks and the main tasks (is that a good name for those tasks?) look the same. The drawback is that it adds a line to the display.

 bitbake/lib/bb/ui/knotty.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
bitbake/lib/bb/ui/knotty.py +7 -4
index 179cea43fa..947fa73a13 100644
@@ -293,10 +293,7 @@ class TerminalFilter(object):
 
             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)
+            msg = "Main tasks (%s of %s)" % (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)
@@ -307,6 +304,12 @@ class TerminalFilter(object):
             print('')
         lines = self.getlines(content)
         if not self.quiet:
+            if not len(activetasks):
+                content = "No running tasks"
+            else:
+                content = "%2s running tasks:" % len(activetasks)
+            print(content)
+            lines += self.getlines(content)
             for tasknum, task in enumerate(tasks[:(self.rows - 1 - lines)]):
                 if isinstance(task, tuple):
                     pbar, progress, rate, start_time = task
#5 lore raw

Re: [bitbake-devel] [PATCH 3/3] knotty.py: Separate the display of main tasks from running tasks

Quoted 10 lines · Peter Kjellerstedt

From: Peter Kjellerstedt <[email protected]>

It can be confusing that the count of running tasks shown together with the progress bar for the main tasks also includes any running setscene tasks.

Separate the display so that the message for the main tasks' progress bar only includes information on the main tasks, and the display of the count of currently running tasks gets it own line.

Quoted 7 lines

---

This should be considered an RFC. With this change, the progress lines for the setscene tasks and the main tasks (is that a good name for those tasks?) look the same. The drawback is that it adds a line to the display.

I'm not keen. The progress bar only relates to "real" tasks, not setscene ones. I know some of the running tasks might be setscene ones but that was a compromise in the previous patches to keep the number of lines minimal. I wasn't convinced that issue mattered that much in reality.

Cheers,

Richard

#6 lore raw

RE: [bitbake-devel] [PATCH 3/3] knotty.py: Separate the display of main tasks from running tasks

Quoted 27 lines

-----Original Message-----
From: Richard Purdie <[email protected]>
Sent: den 7 mars 2022 16:46
To: Peter Kjellerstedt <[email protected]>; bitbake- [email protected]
Subject: Re: [bitbake-devel] [PATCH 3/3] knotty.py: Separate the display of main tasks from running tasks

Quoted 10 lines · Peter Kjellerstedt

From: Peter Kjellerstedt <[email protected]>

It can be confusing that the count of running tasks shown together with the progress bar for the main tasks also includes any running setscene tasks.

Separate the display so that the message for the main tasks' progress bar only includes information on the main tasks, and the display of the count of currently running tasks gets it own line.

Quoted 7 lines

---

This should be considered an RFC. With this change, the progress lines for the setscene tasks and the main tasks (is that a good name for those tasks?) look the same. The drawback is that it adds a line to the display.

Quoted 4 lines

I'm not keen. The progress bar only relates to "real" tasks, not setscene ones. I know some of the running tasks might be setscene ones but that was a compromise in the previous patches to keep the number of lines minimal. I wasn't convinced that issue mattered that much in reality.

As I said, this was just an RFC. I can live without it.

Quoted 4 lines

Cheers,

Richard

//Peter