This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch tpollard/temp in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 6a9db55874f0ed8354aed5677081f3584aa44084 Author: Tom Pollard <[email protected]> AuthorDate: Thu Oct 24 17:04:29 2019 +0100 Add support for logger print header displaying pipeline output --- src/buildstream/_frontend/app.py | 3 +++ src/buildstream/_frontend/widget.py | 6 +++++- src/buildstream/_scheduler/scheduler.py | 5 ++++- src/buildstream/_stream.py | 10 ++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/buildstream/_frontend/app.py b/src/buildstream/_frontend/app.py index 5fe38ce..704a489 100644 --- a/src/buildstream/_frontend/app.py +++ b/src/buildstream/_frontend/app.py @@ -233,6 +233,9 @@ class App: indent=INDENT, ) + # Register the Logline pipeline renderer callback in Stream + self.stream._pipeline_render_callback = self.logger.show_pipeline + # Propagate pipeline feedback to the user self.context.messenger.set_message_handler(self._message_handler) diff --git a/src/buildstream/_frontend/widget.py b/src/buildstream/_frontend/widget.py index 7c846bc..77de825 100644 --- a/src/buildstream/_frontend/widget.py +++ b/src/buildstream/_frontend/widget.py @@ -490,7 +490,11 @@ class LogLine(Widget): # Pipeline state text += self.content_profile.fmt("Pipeline\n", bold=True) - text += self.show_pipeline(stream.total_elements, context.log_element_format) + # Check if the output of show pipeline has already been generated for stream total elements + if stream.total_pipeline_render: + text += stream.total_pipeline_render + else: + text += self.show_pipeline(stream.total_elements, context.log_element_format) text += "\n" # Separator line before following output diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py index ac52b0e..7a85f69 100644 --- a/src/buildstream/_scheduler/scheduler.py +++ b/src/buildstream/_scheduler/scheduler.py @@ -74,6 +74,7 @@ class NotificationType(FastEnum): ELEMENT_TOTALS = "element_totals" FINISH = "finish" SIGTSTP = "sigstp" + SHOW_PIPELINE = "show_pipeline" # Notification() @@ -98,7 +99,8 @@ class Notification: task_error=None, exception=None, task_groups=None, - element_totals=None + element_totals=None, + show_pipeline=None ): self.notification_type = notification_type self.full_name = full_name @@ -111,6 +113,7 @@ class Notification: self.exception = exception self.task_groups = task_groups # Tuple of queue name, complete name, task change, & optional element name self.element_totals = element_totals + self.show_pipeline = show_pipeline # Output of LogLine.show_pipeline() cb, to represent pipeline state # Scheduler() diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index 789e14a..550fa0f 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -94,6 +94,7 @@ class Stream: self.len_session_elements = "" self.len_total_elements = "" self.loop = None + self.total_pipeline_render = None # # Private members @@ -121,6 +122,7 @@ class Stream: self._notify_back_queue = None self._casd_process = None self._watcher = None + self._pipeline_render_callback = None # init() # @@ -1485,6 +1487,12 @@ class Stream: element_totals = str(len(self.session_elements)), str(len(self.total_elements)) self._notify_front(Notification(NotificationType.ELEMENT_TOTALS, element_totals=element_totals)) + # Also send through the pipeline renderer output for heading & summary rendering + total_pipeline_render = self._pipeline_render_callback( # pylint: disable=not-callable + self.total_elements, self._context.log_element_format + ) + self._notify_front(Notification(NotificationType.SHOW_PIPELINE, show_pipeline=total_pipeline_render)) + if self._session_start_callback is not None: self._notify_front(Notification(NotificationType.START)) @@ -1818,6 +1826,8 @@ class Stream: self._session_start_callback() elif notification.notification_type == NotificationType.ELEMENT_TOTALS: self.len_session_elements, self.len_total_elements = notification.element_totals + elif notification.notification_type == NotificationType.SHOW_PIPELINE: + self.total_pipeline_render = notification.show_pipeline elif notification.notification_type == NotificationType.FINISH: if self.loop: self.loop.stop()
