Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-1771

move executionOrder from plugin config class to plugin class

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: meas_base
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

          Hide
          jbosch Jim Bosch added a comment - - edited

          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).

          Show
          jbosch Jim Bosch added a comment - - edited 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).
          Hide
          pgee Perry Gee added a comment -

          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),
          getExecutionOrder=staticmethod(getExecutionOrder)))
          is this a different staticmethod() on is it called for a specific type?

          Show
          pgee Perry Gee added a comment - 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), getExecutionOrder=staticmethod(getExecutionOrder))) is this a different staticmethod() on is it called for a specific type?
          Hide
          jbosch Jim Bosch added a comment -

          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.

          Show
          jbosch Jim Bosch added a comment - 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.
          Hide
          pgee Perry Gee added a comment -

          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?

          Show
          pgee Perry Gee added a comment - 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?
          Hide
          jbosch Jim Bosch added a comment -

          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.

          Show
          jbosch Jim Bosch added a comment - 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.

            People

            Assignee:
            jbosch Jim Bosch
            Reporter:
            jbosch Jim Bosch
            Reviewers:
            Perry Gee
            Watchers:
            Jim Bosch, Kian-Tat Lim, Perry Gee
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Jenkins

                No builds found.