Skip to content

Commit

Permalink
fallback for a cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
mckornfield committed Aug 5, 2024
1 parent c4181f9 commit 2d53c16
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/gretel_trainer/relational/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,12 @@ def list_tables_parents_before_children(self) -> list[str]:
are made, e.g. the following (and others) are all valid outputs:
[p1, p2, c1, c2] or [p2, c2, p1, c1] or [p2, p1, c1, c2] etc.
"""
return list(reversed(list(topological_sort(self.graph))))
try:
return list(reversed(list(topological_sort(self.graph))))
except networkx.NetworkXUnfeasible:
print("Cycle detected")
print(networkx.find_cycle(self.graph))
return list(self.graph.nodes)

def get_primary_key(self, table: str) -> list[str]:
"""
Expand Down

0 comments on commit 2d53c16

Please sign in to comment.