Skip to content

Commit

Permalink
Add a test for transcoding loops of 1 or more nodes (#3810)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Danov <idanov@users.noreply.github.com>
  • Loading branch information
idanov authored Apr 15, 2024
1 parent 7237dc7 commit 28277a6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion kedro/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand Down
24 changes: 23 additions & 1 deletion tests/pipeline/test_pipeline_with_transcoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
"""
Expand Down

0 comments on commit 28277a6

Please sign in to comment.