summaryrefslogtreecommitdiff
path: root/src/buildstream/_frontend
diff options
context:
space:
mode:
authorTom Pollard <tom.pollard@codethink.co.uk>2019-07-31 16:31:47 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-08-08 13:52:36 +0000
commit0026e37918998addb61d7cefcbb9b5f7f6f7b4f4 (patch)
treea756eaf5ba545882f8ec69204759ac22b8112d23 /src/buildstream/_frontend
parent1701aa1239f472317edfc6f675378dc91b1fcd61 (diff)
downloadbuildstream-0026e37918998addb61d7cefcbb9b5f7f6f7b4f4.tar.gz
_message.py: Use element_name & element_key instead of unique_idtpollard/messageobject
Adding the element full name and display key into all element related messages removes the need to look up the plugintable via a plugin unique_id just to retrieve the same values for logging and widget frontend display. Relying on plugintable state is also incompatible if the frontend will be running in a different process, as it will exist in multiple states. The element full name is now displayed instead of the unique_id, such as in the debugging widget. It is also displayed in place of 'name' (i.e including any junction prepend) to be more informative.
Diffstat (limited to 'src/buildstream/_frontend')
-rw-r--r--src/buildstream/_frontend/app.py23
-rw-r--r--src/buildstream/_frontend/widget.py40
2 files changed, 27 insertions, 36 deletions
diff --git a/src/buildstream/_frontend/app.py b/src/buildstream/_frontend/app.py
index a5588e672..826e797e1 100644
--- a/src/buildstream/_frontend/app.py
+++ b/src/buildstream/_frontend/app.py
@@ -31,7 +31,6 @@ from .. import Scope
# Import various buildstream internals
from .._context import Context
-from ..plugin import Plugin
from .._project import Project
from .._exceptions import BstError, StreamError, LoadError, LoadErrorReason, AppError
from .._message import Message, MessageType, unconditional_messages
@@ -474,7 +473,7 @@ class App():
def _message(self, message_type, message, **kwargs):
args = dict(kwargs)
self.context.messenger.message(
- Message(None, message_type, message, **args))
+ Message(message_type, message, **args))
# Exception handler
#
@@ -559,25 +558,22 @@ class App():
# Args:
# action_name (str): The name of the action being performed,
# same as the task group, if it exists
- # full_name (str): The name of this specific task, e.g. the element name
- # unique_id (int): If an element job failed, the unique ID of the element.
+ # full_name (str): The name of this specific task, e.g. the element full name
+ # element (Element): If an element job failed the Element instance
#
- def _job_failed(self, action_name, full_name, unique_id=None):
+ def _job_failed(self, action_name, full_name, element=None):
# Dont attempt to handle a failure if the user has already opted to
# terminate
if not self.stream.terminated:
- if unique_id:
+ if element:
# look-up queue
for q in self.stream.queues:
if q.action_name == action_name:
queue = q
assert queue, "Job action {} does not have a corresponding queue".format(action_name)
- # look-up element
- element = Plugin._lookup(unique_id)
-
# Get the last failure message for additional context
- failure = self._fail_messages.get(element._unique_id)
+ failure = self._fail_messages.get(full_name)
# XXX This is dangerous, sometimes we get the job completed *before*
# the failure message reaches us ??
@@ -585,11 +581,12 @@ class App():
self._status.clear()
click.echo("\n\n\nBUG: Message handling out of sync, " +
"unable to retrieve failure message for element {}\n\n\n\n\n"
- .format(element), err=True)
+ .format(full_name), err=True)
else:
self._handle_failure(element, queue, failure)
else:
+ # Not an element_job, we don't handle the failure
click.echo("\nTerminating all jobs\n", err=True)
self.stream.terminate()
@@ -739,8 +736,8 @@ class App():
return
# Hold on to the failure messages
- if message.message_type in [MessageType.FAIL, MessageType.BUG] and message.unique_id is not None:
- self._fail_messages[message.unique_id] = message
+ if message.message_type in [MessageType.FAIL, MessageType.BUG] and message.element_name is not None:
+ self._fail_messages[message.element_name] = message
# Send to frontend if appropriate
if is_silenced and (message.message_type not in unconditional_messages):
diff --git a/src/buildstream/_frontend/widget.py b/src/buildstream/_frontend/widget.py
index fbde249a9..31f69a539 100644
--- a/src/buildstream/_frontend/widget.py
+++ b/src/buildstream/_frontend/widget.py
@@ -27,11 +27,10 @@ from ruamel import yaml
import click
from .profile import Profile
-from .. import Element, Consistency, Scope
+from .. import Consistency, Scope
from .. import __version__ as bst_version
from .._exceptions import ImplError
from .._message import MessageType
-from ..plugin import Plugin
# These messages are printed a bit differently
@@ -110,12 +109,12 @@ class WallclockTime(Widget):
class Debug(Widget):
def render(self, message):
- unique_id = 0 if message.unique_id is None else message.unique_id
+ element_name = "n/a" if message.element_name is None else message.element_name
text = self.format_profile.fmt('pid:')
text += self.content_profile.fmt("{: <5}".format(message.pid))
- text += self.format_profile.fmt(" id:")
- text += self.content_profile.fmt("{:0>3}".format(unique_id))
+ text += self.format_profile.fmt("element name:")
+ text += self.content_profile.fmt("{: <30}".format(element_name))
return text
@@ -181,11 +180,9 @@ class ElementName(Widget):
def render(self, message):
action_name = message.action_name
- element_id = message.task_id or message.unique_id
- if element_id is not None:
- plugin = Plugin._lookup(element_id)
- name = plugin._get_full_name()
- name = '{: <30}'.format(name)
+ element_name = message.element_name
+ if element_name is not None:
+ name = '{: <30}'.format(element_name)
else:
name = 'core activity'
name = '{: <30}'.format(name)
@@ -215,18 +212,16 @@ class CacheKey(Widget):
def render(self, message):
- element_id = message.task_id or message.unique_id
if not self._key_length:
return ""
- if element_id is None:
+ if message.element_name is None:
return ' ' * self._key_length
missing = False
key = ' ' * self._key_length
- plugin = Plugin._lookup(element_id)
- if isinstance(plugin, Element):
- _, key, missing = plugin._get_display_key()
+ if message.element_key:
+ _, key, missing = message.element_key
if message.message_type in ERROR_MESSAGES:
text = self._err_profile.fmt(key)
@@ -557,12 +552,12 @@ class LogLine(Widget):
if self._failure_messages:
values = OrderedDict()
- for element, messages in sorted(self._failure_messages.items(), key=lambda x: x[0].name):
+ for element_name, messages in sorted(self._failure_messages.items()):
for group in self._state.task_groups.values():
# Exclude the failure messages if the job didn't ultimately fail
# (e.g. succeeded on retry)
- if element.name in group.failed_tasks:
- values[element.name] = ''.join(self._render(v) for v in messages)
+ if element_name in group.failed_tasks:
+ values[element_name] = ''.join(self._render(v) for v in messages)
if values:
text += self.content_profile.fmt("Failure Summary\n", bold=True)
@@ -616,10 +611,9 @@ class LogLine(Widget):
def render(self, message):
# Track logfiles for later use
- element_id = message.task_id or message.unique_id
- if message.message_type in ERROR_MESSAGES and element_id is not None:
- plugin = Plugin._lookup(element_id)
- self._failure_messages[plugin].append(message)
+ element_name = message.element_name
+ if message.message_type in ERROR_MESSAGES and element_name is not None:
+ self._failure_messages[element_name].append(message)
return self._render(message)
@@ -666,7 +660,7 @@ class LogLine(Widget):
if message.detail:
# Identify frontend messages, we never abbreviate these
- frontend_message = not (message.task_id or message.unique_id)
+ frontend_message = not message.element_name
# Split and truncate message detail down to message_lines lines
lines = message.detail.splitlines(True)