def get_child_point(self, from_point, seq): """Return the specific child task point of this trigger. Args: from_point (cylc.flow.cycling.PointBase): base point. seq: the cycling sequence to find the child point. Returns: cylc.flow.cycling.PointBase: cycle point of the child. """ if self.cycle_point_offset is None: point = from_point elif self.offset_is_absolute or self.offset_is_from_icp: # First child is at start of sequence. # E.g. for "R/1/P1 = foo[2] => bar" # foo.2 should spawn bar.1; then we auto-spawn bar.2,3,... point = seq.get_start_point() elif self.offset_is_irregular: # Change offset sign to find children # e.g. -P1D+PT18H to +P1D-PT18H point = get_point_relative( self.cycle_point_offset.translate( self.cycle_point_offset.maketrans('-+', '+-')), from_point) else: point = from_point - get_interval(self.cycle_point_offset) return point
def _get_offset(self, offset=None): """Return and cache the standardised offset string.""" if offset not in self._offsets: if offset: res = get_interval(offset).standardise() else: res = get_interval_cls().get_null_offset() self._offsets[offset] = str(res) return self._offsets[offset]
def get_cleanup_cutoff_point(self, point): """Extract the max dependent cycle point for this point.""" if not self.intercycle_offsets: # This task does not have dependent tasks at other cycles. return point cutoff_points = [] for offset_string, sequence in self.intercycle_offsets: 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(point - get_interval(offset_string)) continue if is_offset_absolute(offset_string): stop_point = sequence.get_stop_point() if stop_point: # Stop point of the sequence is a good cutoff point for an # absolute "offset" cutoff_points.append(stop_point) continue else: # The dependency lasts for the whole run. return None # This is a complicated offset like [02T00-P1W]. dependent_point = sequence.get_start_point() my_cutoff_point = None 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 > point: # Assume monotonic (target_point can never jump back). break if target_point == point: # We have found a dependent_point for point. my_cutoff_point = dependent_point dependent_point = sequence.get_next_point_on_sequence( dependent_point) if my_cutoff_point: # Choose the largest of the dependent points. cutoff_points.append(my_cutoff_point) if cutoff_points: max_cutoff_point = max(cutoff_points) if max_cutoff_point < point: # This is caused by future triggers - default to point. return point return max_cutoff_point # There aren't any dependent tasks in other cycles for point. return point