Ejemplo n.º 1
0
    def get_left(self, inpoint, start_point, base_interval):
        # strip off special outputs
        left = re.sub(':[\w-]+', '', self.left)

        left_graphnode = graphnode(left, base_interval=base_interval)
        if left_graphnode.offset_is_from_ict:
            point = get_point_relative(left_graphnode.offset_string,
                                       start_point)
        elif left_graphnode.offset_string:
            point = get_point_relative(left_graphnode.offset_string, inpoint)
        else:
            point = inpoint
        name = left_graphnode.name

        return TaskID.get(name, point)
Ejemplo n.º 2
0
    def get_left(self, inpoint, start_point, base_interval):
        # strip off special outputs
        left = re.sub(':[\w-]+', '', self.left)

        left_graphnode = graphnode(left, base_interval=base_interval)
        if left_graphnode.offset_is_from_ict:
            point = get_point_relative(left_graphnode.offset_string,
                                       start_point)
        elif left_graphnode.offset_string:
            point = get_point_relative(left_graphnode.offset_string, inpoint)
        else:
            point = inpoint
        name = left_graphnode.name

        return TaskID.get(name, point)
Ejemplo n.º 3
0
    def get_cleanup_cutoff_point(self, my_point, offset_sequence_tuples):
        """Extract the max dependent cycle point for this point."""
        if not offset_sequence_tuples:
            # This task does not have dependent tasks at other cycles.
            return my_point
        cutoff_points = []
        for offset_string, sequence in offset_sequence_tuples:
            if offset_string is None:
                # This indicates a dependency that lasts for the whole run.
                return None
            if sequence is None:
                # This indicates a simple offset interval such as [-PT6H].
                cutoff_points.append(my_point - get_interval(offset_string))
                continue
            # This is a complicated offset like [02T00-P1W].
            dependent_point = sequence.get_start_point()

            matching_dependent_points = []
            while dependent_point is not None:
                # TODO: Is it realistically possible to hang in this loop?
                target_point = (get_point_relative(offset_string,
                                                   dependent_point))
                if target_point > my_point:
                    # Assume monotonic (target_point can never jump back).
                    break
                if target_point == my_point:
                    # We have found a dependent_point for my_point.
                    matching_dependent_points.append(dependent_point)
                dependent_point = sequence.get_next_point_on_sequence(
                    dependent_point)
            if matching_dependent_points:
                # Choose the largest of the dependent points.
                cutoff_points.append(matching_dependent_points[-1])
        if cutoff_points:
            max_cutoff_point = max(cutoff_points)
            if max_cutoff_point < my_point:
                # This is caused by future triggers - default to my_point.
                return my_point
            return max_cutoff_point
        # There aren't any dependent tasks in other cycles for my_point.
        return my_point
Ejemplo n.º 4
0
        def tclass_add_prerequisites(sself, point):
            # NOTE: Task objects hold all triggers defined for the task
            # in all cycling graph sections in this data structure:
            #     self.triggers[sequence] = [list of triggers for this
            #     sequence]
            # The list of triggers associated with sequenceX will only be
            # used by a particular task if the task's cycle point is a
            # valid member of sequenceX's sequence of cycle points.

            # 1) non-conditional triggers
            pp = plain_prerequisites(sself.id, self.start_point)
            sp = plain_prerequisites(sself.id, self.start_point)

            if self.sequential:
                # For tasks declared 'sequential' we automatically add a
                # previous-instance inter-cycle trigger, and adjust the
                # cleanup cutoff (determined by inter-cycle triggers)
                # accordingly.
                p_next = None
                adjusted = []
                for seq in self.sequences:
                    nxt = seq.get_next_point(sself.point)
                    if nxt:
                        # may be None if beyond the sequence bounds
                        adjusted.append(nxt)
                if adjusted:
                    p_next = min(adjusted)
                    if (sself.cleanup_cutoff is not None
                            and sself.cleanup_cutoff < p_next):
                        sself.cleanup_cutoff = p_next

                p_prev = None
                adjusted = []
                for seq in self.sequences:
                    prv = seq.get_nearest_prev_point(sself.point)
                    if prv:
                        # may be None if out of sequence bounds
                        adjusted.append(prv)
                if adjusted:
                    p_prev = max(adjusted)
                    pp.add(TaskID.get(sself.name, str(p_prev)) + ' succeeded')

            for sequence in self.triggers:
                for trig in self.triggers[sequence]:
                    if not sequence.is_valid(sself.point):
                        # This trigger is not used in current cycle
                        continue
                    if (trig.graph_offset_string is None or
                        (get_point_relative(trig.graph_offset_string, point) >=
                         self.start_point)):
                        # i.c.t. can be None after a restart, if one
                        # is not specified in the suite definition.

                        message, prereq_point = trig.get(point)
                        prereq_offset = prereq_point - point
                        if (prereq_offset > get_interval_cls().get_null() and
                            (sself.max_future_prereq_offset is None or
                             prereq_offset > sself.max_future_prereq_offset)):
                            sself.max_future_prereq_offset = prereq_offset

                        if trig.suicide:
                            sp.add(message)
                        else:
                            pp.add(message)

            sself.prerequisites.add_requisites(pp)
            sself.suicide_prerequisites.add_requisites(sp)

            # 2) conditional triggers
            for sequence in self.cond_triggers.keys():
                for ctrig, exp in self.cond_triggers[sequence]:
                    foo = ctrig.keys()[0]
                    if not sequence.is_valid(sself.point):
                        # This trigger is not valid for current cycle (see NOTE just above)
                        continue
                    cp = conditional_prerequisites(sself.id, self.start_point)
                    for label in ctrig:
                        trig = ctrig[label]
                        if trig.graph_offset_string is not None:
                            is_less_than_start = (get_point_relative(
                                trig.graph_offset_string, point) <
                                                  self.start_point)
                            cp.add(
                                trig.get(point)[0], label, is_less_than_start)
                        else:
                            cp.add(trig.get(point)[0], label)
                    cp.set_condition(exp)
                    if ctrig[foo].suicide:
                        sself.suicide_prerequisites.add_requisites(cp)
                    else:
                        sself.prerequisites.add_requisites(cp)