Uploaded image for project: 'Gump'
  1. Gump
  2. GUMP-104

design a way to walk part of the tree very efficiently

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Gump3-alpha-4
    • Gump3-alpha-4
    • Python-based Gump
    • None

    Description

      We need a convention between plugins that enables them to communicate about the state of the tree, and make somewhat intelligent decisions about what to build and what not to build. Ideally that is extracted nearly completely into a few "policy" or "algorithm" plugins.

      Perhaps
      {{{
      class DependencyStateVerifierPlugin(AbstractPlugin):
      def visit_project(p):
      for rel in p.dependencies:
      if p.rel.dependency.state == FAILED:
      p.state == PREREQ_FAILURE

      class AbstractBuilderPlugin(AbstractPlugin):
      def visit_project(p):
      if not p.rel.dependency.state == PREREQ_FAILURE and getattr(self, "do_build", None):
      self.do_build(p)

      1. NB: MkdirPlugin doesn't need to know about project states, but it still depends on the policy in
      2. AbstractBuilderPlugin
        class MkdirPlugin(AbstractBuilderPlugin):
        def do_filter(p):
        for c in p.commands:
        if isinstance(c,gump.model.Mkdir)
        yield c

      def do_build(p):
      for c in do_filter(p):
      raise NotImplementedError, "TODO: actually create a directory here"
      }}}

      Or maybe we'd like

      {{{
      class DependencyStateVerifierPlugin(AbstractPlugin):
      def visit_project(p):
      for rel in p.dependencies:
      if p.rel.dependency.state <= FAILED:
      p.state == PREREQ_FAILURE

      class StateAwareWalker(Walker):
      def filter_walk(visitor,project):
      if project.state <= FAILED and not has_attribute(visitor.visit_project, "visit_failed"):
      return
      yield y

      1. NB: the builder plugins are now cleaner again but the mkdir plugin knows that
      2. it only wants to visit successful projects...
        class MkdirPlugin(AbstractPlugin):
        @visit_failed
        visit_project(p):
        raise NotImplementedError, "TODO: actually create a directory here"
        }}}

      hmm. It might make sense to have a FilteringWalker that supports a different kind of plugin, where that plugin can tell the walker to not walk some projects. Ugh!

      I have a hunch that the real thing to do here is get up to speed on all python's fancy list comprehensions, generators and generator expressions. There's probably a real elegant way to do this...

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              lsimons Leo Simons
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: