diff --git a/kedro/pipeline/pipeline.py b/kedro/pipeline/pipeline.py index 29d647b387..5a0d63b4cf 100644 --- a/kedro/pipeline/pipeline.py +++ b/kedro/pipeline/pipeline.py @@ -171,7 +171,8 @@ def __init__( try: self._toposorter.prepare() except CycleError as exc: - message = f"Circular dependencies exist among these items: {exc.args[1]}" + loop = list(set(exc.args[1])) + message = f"Circular dependencies exist among the following {len(loop)} item(s): {loop}" raise CircularDependencyError(message) from exc self._toposorted_nodes: list[Node] = [] diff --git a/tests/pipeline/test_pipeline_with_transcoding.py b/tests/pipeline/test_pipeline_with_transcoding.py index c8dc87441a..7e4ad04056 100644 --- a/tests/pipeline/test_pipeline_with_transcoding.py +++ b/tests/pipeline/test_pipeline_with_transcoding.py @@ -5,7 +5,11 @@ import kedro from kedro.pipeline import node from kedro.pipeline.modular_pipeline import pipeline as modular_pipeline -from kedro.pipeline.pipeline import OutputNotUniqueError, _strip_transcoding +from kedro.pipeline.pipeline import ( + CircularDependencyError, + OutputNotUniqueError, + _strip_transcoding, +) # Different dummy func based on the number of arguments @@ -177,6 +181,24 @@ def test_duplicates_in_transcoded_outputs(self): ] ) + def test_transcoding_loop(self): + with pytest.raises(CircularDependencyError, match="node1"): + modular_pipeline( + [ + node(identity, "A@pandas", "B@pandas", name="node1"), + node(identity, "B@spark", "C@spark", name="node2"), + node(identity, "C@spark", "A@spark", name="node3"), + ] + ) + + def test_transcoding_self_reference(self): + with pytest.raises(CircularDependencyError, match="node1"): + modular_pipeline( + [ + node(identity, "A@pandas", "A@spark", name="node1"), + ] + ) + class TestComplexPipelineWithTranscoding: """