Skip to content

Commit

Permalink
Improve warning output in pipeline.projects.provenance.util.SalesTree.
Browse files Browse the repository at this point in the history
  • Loading branch information
kasei committed Sep 27, 2019
1 parent b6e1a03 commit 1c93304
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pipeline/projects/provenance/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def __init__(self):
self.nodes = {}
self.nodes_rev = {}
self.outgoing_edges = {}
self.incoming_edges = {}

def add_node(self, node):
if node not in self.nodes:
Expand Down Expand Up @@ -122,7 +121,6 @@ def add_edge(self, src, dst):
else:
warnings.warn(f'*** {src} already has an outgoing edge: {self.outgoing_edges[i]}')
self.outgoing_edges[i] = j
self.incoming_edges[j] = i

def __iter__(self):
for i in self.outgoing_edges.keys():
Expand All @@ -139,7 +137,6 @@ def load(f):
g.nodes_rev = {int(i): tuple(n) for i, n in d['nodes'].items()}
g.nodes = {n: i for i, n in g.nodes_rev.items()}
g.outgoing_edges = {int(k): int(v) for k, v in d['outgoing'].items()}
g.incoming_edges = {v: k for k, v in g.outgoing_edges.items()}
return g

def dump(self, f):
Expand All @@ -155,6 +152,7 @@ def canonical_key(self, src):
key = src
steps = 0
seen = {key}
path = [key]
while True:
if key not in self.nodes:
break
Expand All @@ -168,9 +166,12 @@ def canonical_key(self, src):
warnings.warn(f'*** Self-loop found in post sale data: {key!s:<40}')
break
if parent in seen:
warnings.warn(f'*** Loop found in post sale data: {key!s:<40} -> {parent!s:<40}')
path.append(parent)
warnings.warn(f'*** Loop found in post sale data: {path}')
# warnings.warn(f'*** Loop found in post sale data: {key!s:<40} -> {parent!s:<40}')
break
seen.add(parent)
key = parent
seen.add(key)
path.append(key)
steps += 1
return key, steps

0 comments on commit 1c93304

Please sign in to comment.