Skip to content

Commit

Permalink
graph gen functional
Browse files Browse the repository at this point in the history
  • Loading branch information
dwsutherland committed Sep 15, 2020
1 parent a6f422e commit d58fa81
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 315 deletions.
97 changes: 0 additions & 97 deletions cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1994,103 +1994,6 @@ def get_graph_raw(self, start_point_string, stop_point_string,
self._last_graph_raw_edges = graph_raw_edges
return graph_raw_edges

def get_graph_edges(self, start_point, stop_point):
"""Convert the abstract graph edges (self.edges, etc) to actual edges
This method differs from the get_graph_raw; class attributes are not
used to hold information from previous method calls, and only ungrouped
edges are returned.
Args:
start_point (cylc.flow.cycling.*Point):
Start Integer or ISO8601 Point.
stop_point (cylc.flow.cycling.*Point):
Stop Integer or ISO8601 Point.
"""

if start_point is None:
raise TypeError(
"get_graph_edges() start_point argument must be a"
" valid cycle point, not 'NoneType'")
# Avoid infinite edge generation
if stop_point is None:
raise TypeError(
"get_graph_edges() stop_point argument must be a"
" valid cycle point, not 'NoneType'")
suite_final_point = get_point(
self.cfg['scheduling']['final cycle point'])

# Get ICP on-sequence point
actual_first_point = self.get_actual_first_point(self.start_point)

gr_edges = {}
start_point_offset_cache = {}
point_offset_cache = None
for sequence, edges in self.edges.items():
# Get first cycle point for this sequence
point = sequence.get_first_point(start_point)
while point is not None:
if point > stop_point:
# Beyond requested final cycle point.
break
if suite_final_point is not None and point > suite_final_point:
# Beyond suite final cycle point.
break
point_offset_cache = {}
for left, right, suicide, cond in edges:
if right:
r_id = (right, point)
else:
r_id = None
if left.startswith('@'):
# @trigger node.
name = left
offset_is_from_icp = False
offset = None
else:
name, offset, _, offset_is_from_icp, _, _ = (
GraphNodeParser.get_inst().parse(left))
if offset:
if offset_is_from_icp:
cache = start_point_offset_cache
# use actual ICP first point
rel_point = actual_first_point
else:
cache = point_offset_cache
rel_point = point
try:
l_point = cache[offset]
except KeyError:
l_point = get_point_relative(offset, rel_point)
cache[offset] = l_point
else:
l_point = point
l_id = (name, l_point)

if l_id is None and r_id is None:
continue
if l_id is not None and actual_first_point > l_id[1]:
# Check that l_id is not earlier than start time.
if r_id is None or r_id[1] < actual_first_point:
continue
# Pre-initial dependency;
# keep right hand node.
l_id = r_id
r_id = None
if point not in gr_edges:
gr_edges[point] = []
# only used to get task ID here
lstr, rstr = self._close_families(l_id, r_id, {})
gr_edges[point].append((lstr, rstr, None, suicide, cond))
# Increment the cycle point.
point = sequence.get_next_point_on_sequence(point)

del start_point_offset_cache
del point_offset_cache
GraphNodeParser.get_inst().clear()
# Flatten nested list.
return [i for sublist in gr_edges.values() for i in sublist]

def get_node_labels(self, start_point_string, stop_point_string=None):
"""Return dependency graph node labels."""
stop_point = None
Expand Down
Loading

0 comments on commit d58fa81

Please sign in to comment.