Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test for transcoding loops of 1 or more nodes #3810

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test won't be needed after #3812 merge, so just pointing here not to forget about that

with pytest.raises(CircularDependencyError, match="node1"):
modular_pipeline(
[
node(identity, "A@pandas", "A@spark", name="node1"),
]
)


class TestComplexPipelineWithTranscoding:
"""
Expand Down