Proof of Concept for libtaskotron extensions
AbandonedPublic

Authored by tflink on Sep 15 2015, 2:26 AM.

Details

Summary

This is a proof of concept meant to start a discussion about and show some of the possible benefits of implementing an extension system for libtaskotron. The code is rather rough but it does work.

The primary benefits I see from doing this would be:

  • reducing the dependencies needed when only using a part of libtaskotron (only libtaskotron and libtaskotron-fedora would be needed for local execution)
  • enabling the use of libtaskotron on non-fedora platforms (CentOS, debian etc.)

I went with a outside-system-site-packages approach here for two reasons:

  • don't have to worry as much about getting unintended modules from site-packages
  • we don't need a setup.py for each extension - the files can just be added to /usr/share/libtaskotron
  • all the core extensions can remain in the libtaskotron repo, limiting the PITA when trying to work on extensions and the base at the same time

If we go forward with this, it'll need more attention to detail and a lot of polish but I'm happy with it as a proof-of-concept. Thoughts on this approach?

Test Plan

I haven't tested this with anything other than task-rpmlint. Some modules have moved around, so changes to task code may also be needed

Diff Detail

Repository
rLTRN libtaskotron
Branch
feature/module-poc
Lint
Lint SkippedExcuse: this is a proof-of-concept with known issues. good enough for discussion and shouldn't be pushed to remote as-is
Unit
Unit Tests Skipped
Build Status
Buildable 208
Build 208: arc lint + arc unit
tflink retitled this revision from to Proof of Concept for libtaskotron extensions.Sep 15 2015, 2:26 AM
tflink updated this object.
tflink edited the test plan for this revision. (Show Details)
tflink added reviewers: jskladan, kparal, mkrizek, lbrabec.
tflink set the repository for this revision to rLTRN libtaskotron.
tflink added a project: libtaskotron.
tflink added a subscriber: ngompa.

One other thing - the base for this still requires dnf and hawkey. the runner requires rpm_utils so I didn't see a point in moving that to extensions/fedora since the runner will be undergoing some pretty big changes soon anyways.

If we go forward with this, it'd be after the big rename/refactor but I wanted to write against a stable base so this is against current disposable-develop

bump/ping

Was hoping for some feedback and thoughts on the general approach - whether this is worth pursuing or not. Now that f23 beta's been released, was hoping folks might have more time to look at it

Ignoring that the rpm_utils module isn't being refactored out yet, the approach looks pretty solid. It looks like a solid foundation to develop a useful, distro-agnostic test framework. With the split of the module out, is it now possible to use libtaskotron in a purely Python 3 environment?

I haven't run or studied the code in detail but the approach overall looks good to me.

kparal added a comment.Oct 2 2015, 8:27 AM

The code in exthook and changes in runner are very difficult to read and (I suppose) a hell to debug.

Why exactly do we need to use this? I thought the split would be easy, keep everything as it is (shuffle the files into dirs if needed), and just package them into separate RPM files. Add a bit of inconvenient logic "import foo or do something else". I don't understand much the reasons why moving stuff into /usr/share is better, can you expand on that? The module loader is ugly and it reminds me of autotest, which placed modules into completely unexpected places and then used dark magic when rewriting the imported names using arcane rules. I hated working on it, because I spent considerable time just locating a particular module on disk. (They said they were trying to get away from that with avocado).

Can't we simply put everything into libtaskotron/ext/ and then install it into the same location in site-modules? If multiple setup.py files are needed for that, OK, no big deal, we have doit to do it :-) I don't understand the other concerns, please explain. Thanks.

extensions/fedora/directives/createrepo_directive.py
1

I'd expect createrepo to be usable outside of fedora as well (I guess other RPM distributions also use it). Does it make sense to have it in extensions/fedora/directives? Where do we place it instead? Into libtaskotron/ext/directives? Into extensions/common/directives? And package it as a part of core libtaskotron?

libtaskotron.spec
72

We could name this something like libtaskotron-remote and move python-paramiko dependency into it as well. Thoughts?

libtaskotron/exthook.py
13

Holy crap. That looks scary.

tflink added a comment.Oct 2 2015, 3:21 PM

Why exactly do we need to use this? I thought the split would be easy, keep everything as it is (shuffle the files into dirs if needed), and just package them into separate RPM files. Add a bit of inconvenient logic "import foo or do something else". I don't understand much the reasons why moving stuff into /usr/share is better, can you expand on that? The module loader is ugly and it reminds me of autotest, which placed modules into completely unexpected places and then used dark magic when rewriting the imported names using arcane rules. I hated working on it, because I spent considerable time just locating a particular module on disk. (They said they were trying to get away from that with avocado).

I was trying to avoid putting the code into different repositories and needing more setup.py files in a different namespace and this allows for directives in the extension as well. I also wanted to create an actual extension system instead of splitting our code up into subpackages and calling it "extensions" that only we can use.

Complexity-wise, I didn't see a whole lot of difference between loading namepace-ish extensions (doing taskotron_ext.* modules or something like that) and having a single location from which we could import extension code and directives.

Can't we simply put everything into libtaskotron/ext/ and then install it into the same location in site-modules? If multiple setup.py files are needed for that, OK, no big deal, we have doit to do it :-) I don't understand the other concerns, please explain. Thanks.

That's how Flask used to do it but that has changed. I didn't get to the bottom of exactly why that changed other than it was swallowing exceptions and I figure they wouldn't have made a change that broke existing Flask extensions if there wasn't a good reason for it.

I also worry about having one common directory in site_packages that a bunch of stuff is getting installed into after bypassing any of python's mechanisms for installation - it smells like something that would cause problems sooner or later.

I'll see if I can come up with a different way of doing extensions

tflink planned changes to this revision.Oct 2 2015, 4:41 PM

I think I've found a better way to do this, will post new patch when it's ready

In D581#11613, @tflink wrote:

I was trying to avoid putting the code into different repositories

I'm sorry, I'm really slow - why would different repositories be needed?

I also wanted to create an actual extension system instead of splitting our code up into subpackages and calling it "extensions" that only we can use.

What should this extension system be able to do? Because I thought we wanted to do the former, a split to subpackages. Who else should be able to use the extensions? Some other library, instead of importing libtaskotron and using it through it?

That's how Flask used to do it but that has changed. I didn't get to the bottom of exactly why that changed other than it was swallowing exceptions and I figure they wouldn't have made a change that broke existing Flask extensions if there wasn't a good reason for it.

I'm not familiar with Flask, but that commit seems to rework is_important_traceback() method which sounds relevant to the commit title - maybe a different way of importing modules is just a byproduct?

I also worry about having one common directory in site_packages that a bunch of stuff is getting installed into after bypassing any of python's mechanisms for installation - it smells like something that would cause problems sooner or later.

So, are you saying we can't use python standard install mechanism (setup.py) to install files foo.py, bar.py into /usr/share/python2.7/site-packages/libtaskotron/ext/common and then a different setup.py to install baz.py into the same directory? Or am I completely misunderstanding this?

tflink abandoned this revision.Oct 6 2015, 5:01 PM

After chatting with @kparal some more, I'm really over engineering this for what the current use cases are. We have a saner-for-now approach that isn't going to take quite so much effort to implement which I will put in a new review