Patchwork [bitbake-devel,6/7] bitbake: event: adding events to allow bbclasses to push custom info

login
register
mail settings
Submitter Alexandru DAMIAN
Date Sept. 16, 2013, 1:33 p.m.
Message ID <389466a059c3e6ba345bec88bb710f9dd3311189.1379338189.git.alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/58153/
State New
Headers show

Comments

Alexandru DAMIAN - Sept. 16, 2013, 1:33 p.m.
From: Alexandru DAMIAN <alexandru.damian@intel.com>

We add a new event that will be triggered by the
package-building class, containing the information
about the currently built package.

Adding an event that will passi information about the
content of each package file that gets built.

Knotty UI will ignore these events by default.

Maybe a mechanism for using a single generic event is in order ?

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 bitbake/lib/bb/event.py     | 16 ++++++++++++++++
 bitbake/lib/bb/ui/knotty.py |  2 ++
 2 files changed, 18 insertions(+)
Richard Purdie - Sept. 16, 2013, 1:46 p.m.
On Mon, 2013-09-16 at 14:33 +0100, Alex DAMIAN wrote:
> From: Alexandru DAMIAN <alexandru.damian@intel.com>
> 
> We add a new event that will be triggered by the
> package-building class, containing the information
> about the currently built package.
> 
> Adding an event that will passi information about the
> content of each package file that gets built.
> 
> Knotty UI will ignore these events by default.
> 
> Maybe a mechanism for using a single generic event is in order ?
> 
> Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
> ---
>  bitbake/lib/bb/event.py     | 16 ++++++++++++++++
>  bitbake/lib/bb/ui/knotty.py |  2 ++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
> index 67cfcea..7dd9236 100644
> --- a/bitbake/lib/bb/event.py
> +++ b/bitbake/lib/bb/event.py
> @@ -589,6 +589,22 @@ class PackageInfo(Event):
>          Event.__init__(self)
>          self._pkginfolist = pkginfolist
>  
> +class SinglePackageInfo(Event):
> +    """
> +    Single Package Information sent on emit_pkgdata
> +    """
> +    def __init__(self, data):
> +        Event.__init__(self)
> +        self._data = data
> +
> +class PackageFileSizes(Event):
> +    """
> +    Event that contains information about the file sizes contained in a package.
> +    """
> +    def __init__(self, data):
> +        Event.__init__(self)
> +        self._data = data
> +
>  class SanityCheck(Event):
>      """

Your explanation in the commit message isn't as detailed as it could
be. 

I'm guessing but I suspect the problem we have is that the event cannot
be rebuilt on the other side of an XMLRPC connection without having the
event class in a common namespace?

This is therefore a hack to allow the event to exist in all the client
side namespaces.

Ideally we should really have an API which allows the classes themselves
to declare their event formats and not require adding to event.py every
time a new piece of code/event is added.

Presumably there is some change required to OE-Core in order for this
get used to?

Is the PackageFileSizes not contained in the other event data?

I appreciate we allowed PackageInfo in but I didn't like it at the time,
I like it even less now I see we're just going to keep doing this :(.

>      Event to issue sanity check
> diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
> index 0211b50..03baa75 100644
> --- a/bitbake/lib/bb/ui/knotty.py
> +++ b/bitbake/lib/bb/ui/knotty.py
> @@ -477,6 +477,8 @@ def main(server, eventHandler, params, tf = TerminalFilter):
>  
>              # ignore
>              if isinstance(event, (bb.event.BuildBase,
> +                                  bb.event.PackageFileSizes,
> +                                  bb.event.SinglePackageInfo,
>                                    bb.event.StampUpdate,
>                                    bb.event.ConfigParsed,
>                                    bb.event.RecipeParsed,


Given the event masking that is now in knotty, do we need to do this?
Can't we remove this block?

Cheers,

Richard
Alexandru DAMIAN - Sept. 16, 2013, 1:56 p.m.
On Mon, Sep 16, 2013 at 2:46 PM, Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> On Mon, 2013-09-16 at 14:33 +0100, Alex DAMIAN wrote:
> > From: Alexandru DAMIAN <alexandru.damian@intel.com>
> >
> > We add a new event that will be triggered by the
> > package-building class, containing the information
> > about the currently built package.
> >
> > Adding an event that will passi information about the
> > content of each package file that gets built.
> >
> > Knotty UI will ignore these events by default.
> >
> > Maybe a mechanism for using a single generic event is in order ?
> >
> > Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
> > ---
> >  bitbake/lib/bb/event.py     | 16 ++++++++++++++++
> >  bitbake/lib/bb/ui/knotty.py |  2 ++
> >  2 files changed, 18 insertions(+)
> >
> > diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
> > index 67cfcea..7dd9236 100644
> > --- a/bitbake/lib/bb/event.py
> > +++ b/bitbake/lib/bb/event.py
> > @@ -589,6 +589,22 @@ class PackageInfo(Event):
> >          Event.__init__(self)
> >          self._pkginfolist = pkginfolist
> >
> > +class SinglePackageInfo(Event):
> > +    """
> > +    Single Package Information sent on emit_pkgdata
> > +    """
> > +    def __init__(self, data):
> > +        Event.__init__(self)
> > +        self._data = data
> > +
> > +class PackageFileSizes(Event):
> > +    """
> > +    Event that contains information about the file sizes contained in a
> package.
> > +    """
> > +    def __init__(self, data):
> > +        Event.__init__(self)
> > +        self._data = data
> > +
> >  class SanityCheck(Event):
> >      """
>
> Your explanation in the commit message isn't as detailed as it could
> be.
>
> I'm guessing but I suspect the problem we have is that the event cannot
> be rebuilt on the other side of an XMLRPC connection without having the
> event class in a common namespace?
>
> This is therefore a hack to allow the event to exist in all the client
> side namespaces.
>

[Alex] Yep, this is an ugly hack.


>
> Ideally we should really have an API which allows the classes themselves
> to declare their event formats and not require adding to event.py every
> time a new piece of code/event is added.
>

[Alex] I would favor a single "GenericEvent" that will take a set of
defined parameters,
that would allow "subclassing" at runtime - sort of introspection if you
will.

Something like this:

class GenericInfo(Event):
    def __init__(self, type, data):
        Event.__init__(self)
        self._type = type
        self._data = data

with a call like

bb.event.fire(bb.event.GenericInfo("PackageInfo", pkginfolist), e.data)

the UI handlers / anybody would subscribe to GenericInfo events,
and the processing code would look like:

if isinstance(event, bb.event.GenericInfo):
    if event._type == "PackageInfo":
         savePackageInfo(event)
    elif event._type == "PackageFileSizes":
        ....


What do you think ?


>
> Presumably there is some change required to OE-Core in order for this
> get used to?
>

The code using the e

>
> Is the PackageFileSizes not contained in the other event data?
>

[Alex] Not  that I could find.

>
> I appreciate we allowed PackageInfo in but I didn't like it at the time,
> I like it even less now I see we're just going to keep doing this :(.
>
> >      Event to issue sanity check
> > diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
> > index 0211b50..03baa75 100644
> > --- a/bitbake/lib/bb/ui/knotty.py
> > +++ b/bitbake/lib/bb/ui/knotty.py
> > @@ -477,6 +477,8 @@ def main(server, eventHandler, params, tf =
> TerminalFilter):
> >
> >              # ignore
> >              if isinstance(event, (bb.event.BuildBase,
> > +                                  bb.event.PackageFileSizes,
> > +                                  bb.event.SinglePackageInfo,
> >                                    bb.event.StampUpdate,
> >                                    bb.event.ConfigParsed,
> >                                    bb.event.RecipeParsed,
>
>
> Given the event masking that is now in knotty, do we need to do this?
> Can't we remove this block?
>

[Alex] Yep, it should get removed. I refrained from doing so since it
wasn't deleted
when the subscription code got merged in.


> Cheers,
>
> Richard
>
>
>
Richard Purdie - Sept. 16, 2013, 3:20 p.m.
On Mon, 2013-09-16 at 14:56 +0100, Damian, Alexandru wrote:
> On Mon, Sep 16, 2013 at 2:46 PM, Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:

> Your explanation in the commit message isn't as detailed as it could
>         be.
>         
>         I'm guessing but I suspect the problem we have is that the
>         event cannot
>         be rebuilt on the other side of an XMLRPC connection without
>         having the
>         event class in a common namespace?
>         
>         This is therefore a hack to allow the event to exist in all
>         the client
>         side namespaces.
> 
> 
> [Alex] Yep, this is an ugly hack.

In future *please* put this kind of information into commit messages.
I'm having a lot of trouble with these patches as the commit messages
don't give me all the information I need to review them.


>  
>         
>         Ideally we should really have an API which allows the classes
>         themselves
>         to declare their event formats and not require adding to
>         event.py every
>         time a new piece of code/event is added.

> 
> [Alex] I would favor a single "GenericEvent" that will take a set of
> defined parameters,
> that would allow "subclassing" at runtime - sort of introspection if
> you will.
> 
> Something like this:
> 
> 
> class GenericInfo(Event):
> 
>     def __init__(self, type, data):
>         Event.__init__(self)
>         self._type = type
>         self._data = data
> 
> with a call like
> 
> 
> bb.event.fire(bb.event.GenericInfo("PackageInfo", pkginfolist),
> e.data)
> 
> 
> the UI handlers / anybody would subscribe to GenericInfo events, 
> and the processing code would look like:
> 
> 
> if isinstance(event, bb.event.GenericInfo):
>     if event._type == "PackageInfo":
>          savePackageInfo(event)
>     elif event._type == "PackageFileSizes":
>         ....
> 

Lets do it but can you:

a) Stop using the underscores please. I know some older events have them
but the data is not internal so lets not persist broken syntax going
forward.
b) Call this MetadataEvent and put in a header comment explaining what
it is and why/when you'd use it.
c) Convert the user of PackageInfo in OE-Core to use the new event if it
is available, falling back to PackageInfo.
d) Update hob to accept the new event

c/d can come later but I do want to see patches for them ultimately.
We'll remove PackageInfo in the 1.6 cycle.

Cheers,

Richard

Patch

diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 67cfcea..7dd9236 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -589,6 +589,22 @@  class PackageInfo(Event):
         Event.__init__(self)
         self._pkginfolist = pkginfolist
 
+class SinglePackageInfo(Event):
+    """
+    Single Package Information sent on emit_pkgdata
+    """
+    def __init__(self, data):
+        Event.__init__(self)
+        self._data = data
+
+class PackageFileSizes(Event):
+    """
+    Event that contains information about the file sizes contained in a package.
+    """
+    def __init__(self, data):
+        Event.__init__(self)
+        self._data = data
+
 class SanityCheck(Event):
     """
     Event to issue sanity check
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 0211b50..03baa75 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -477,6 +477,8 @@  def main(server, eventHandler, params, tf = TerminalFilter):
 
             # ignore
             if isinstance(event, (bb.event.BuildBase,
+                                  bb.event.PackageFileSizes,
+                                  bb.event.SinglePackageInfo,
                                   bb.event.StampUpdate,
                                   bb.event.ConfigParsed,
                                   bb.event.RecipeParsed,