From 2d53c1662f1ad1c2f2856f900e278369ed0d2fc9 Mon Sep 17 00:00:00 2001 From: Matt Kornfield Date: Mon, 5 Aug 2024 14:49:21 -0700 Subject: [PATCH] fallback for a cycle --- src/gretel_trainer/relational/core.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gretel_trainer/relational/core.py b/src/gretel_trainer/relational/core.py index e9a0422d..9ff6b7dc 100644 --- a/src/gretel_trainer/relational/core.py +++ b/src/gretel_trainer/relational/core.py @@ -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]: """