def __init__(self, parent, name, **kwargs):
        """
        Constructor. May also have properties/attributes passed.

        The difference between the assignment of a property using 
        property_assign versus pre_assign and post_assign is that 
        changes made using property_assign are task-local, i.e. they are 
        not visible to other tasks.
        Similarly, "defines" are properties that, once defined, can no 
        longer be modified.

        @type  parent: Workflow
        @param parent: A reference to the parent (usually a workflow).
        @type  name: string
        @param name: A name for the task.
        @type  kwargs: dict
        @param kwargs: The following options are supported:
            - lock: a list of locks that is aquired on entry of
              execute() and released on leave of execute().
            - property_assign: a list of attribute name/value pairs
            - pre_assign: a list of attribute name/value pairs
            - post_assign: a list of attribute name/value pairs
        """
        assert parent is not None
        assert name   is not None
        Trackable.__init__(self)
        self._parent     = parent
        self.id          = None
        self.name        = str(name)
        self.description = kwargs.get('description', '')
        self.inputs      = []
        self.outputs     = []
        self.manual      = False
        self.internal    = False  # Only for easing debugging.
        self.cancelled   = False
        self.properties  = kwargs.get('properties',  {})
        self.defines     = kwargs.get('defines',     {})
        self.pre_assign  = kwargs.get('pre_assign',  [])
        self.post_assign = kwargs.get('post_assign', [])
        self.locks       = kwargs.get('lock',        [])
        self.lookahead   = 2  # Maximum number of MAYBE predictions.
        self._parent._add_notify(self)
        self.properties.update(self.defines)
        assert self.id is not None
Exemple #2
0
    def __init__(self, workflow, **kwargs):
        """
        Constructor.
        """
        Trackable.__init__(self)
        assert workflow is not None
        self.workflow        = workflow
        self.attributes      = {}
        self.outer_job       = kwargs.get('parent', self)
        self.locks           = {}
        self.last_node       = None
        self.task_tree       = Task(self, Tasks.Simple(workflow, 'Root'))
        self.success         = True
        self.debug           = False

        # Prevent the root node from being executed.
        self.task_tree.state = Task.COMPLETED
        start                = self.task_tree._add_child(workflow.start)

        workflow.start._predict(start)
        if not kwargs.has_key('parent'):
            start.spec._update_state(start)