Fix Version/s: None
Sprint:Science Pipelines DM-W15-4
Team:Data Release Production
We originally put the executionOrder parameter (which determines when a plugin is run, relative to others), in the config object, simply because that's where it was in the old framework. But it's really not something that should be configurable, as it depends only on the inputs the algorithm needs, which don't change.
I wasn't confused about what the call to type() did, but I was confused about how it does it. When I looked up staticmethod() in the Python 2.7 documentation, it said that staticmethod() had to be called on a class or class instance. But in your code, it is not called on a class instance, or at least not on the AlgClass which is passed to type. So call:
PluginClass = type(AlgClass._name_ + Base._name_, (Base,),
dict(AlgClass=AlgClass, ConfigClass=ConfigClass, factory=staticmethod(factory),
is this a different staticmethod() on is it called for a specific type?
I think you just misunderstood the Python docs; they were saying that once you've created a static method, you can call that static method via either a class or a class instance.
Yes, I did see that staticmethod is really a built-in in another place, but I am still confused about how it gets attached to the created class.
Are you saying that staticmethod(factory) makes a generical static method of factory, and it becomes AlgClass.factory because it is in the dict?
Yes, exactly. Everything in that dict ends up attached to the class, and you can think of staticmethod as a wrapper that just makes sure that factory never gets a "self" argument, regardless of how its called.
Your guess on the use of staticmethod() in wrappers.py was exactly right - it's how to use those "@" decorators in dynamically-created classes.
In fact, that's all Python's "@" syntax does: @staticmethod followed by a function calls staticmethod() with the original function as an argument, and then uses what staticmethod() returns instead of the original function. Here's a more complete tutorial on that: http://thecodeship.com/patterns/guide-to-python-function-decorators/.
And I'll add your suggested comment on execution order; the question of whether we need a more sophisticated system does keep coming up (and I still don't think we need one).