Skip to content

[sdk] Python SDK topological_sort does not detect cyclic task dependencies #12675

@Riddhima8

Description

@Riddhima8

Environment

Description

The local graph utility used for pipeline task ordering does not explicitly detect
cyclic dependencies.

Steps to reproduce

Minimal reproducible example:

from kfp.local import graph_utils

graph = {
    'A': ['B'],
    'B': ['A'],
}

graph_utils.topological_sort(graph)

Expected result

The function should fail fast with a clear and user-friendly error
(e.g. ValueError) indicating that a cyclic dependency was detected.

Since topological sorting is only defined for DAGs, cyclic task
dependencies should be treated as a user error during local execution.

Materials and Reference

  • Source code under discussion:
    sdk/python/kfp/local/graph_utils.py

  • Background reference:
    Topological sorting is only defined for directed acyclic graphs (DAGs).
    Cyclic task dependencies represent a user error and should be detected
    explicitly during local pipeline execution.


Impacted by this bug? Give it a 👍.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions