mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Workflow Edge Groups (#393)
* Introducing edge groups * Add conditional and partitioning edge groups; next add samples and tests * Add unit tests * Add samples * Address comments 1 * Address comments 2 * Update conditional edge group to take in cases and default * Minor updates to sample * Collapsing Paritioning Edge group and Conditional Edge group to source edge group * Improve sample clarity * Name consolidation --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
19d91bb950
commit
ed86baa6cb
@@ -17,7 +17,7 @@ from agent_framework_workflow import (
|
||||
handler,
|
||||
validate_workflow_graph,
|
||||
)
|
||||
from agent_framework_workflow._edge import Edge
|
||||
from agent_framework_workflow._edge import SingleEdgeGroup
|
||||
|
||||
|
||||
class StringExecutor(Executor):
|
||||
@@ -159,10 +159,13 @@ def test_graph_connectivity_isolated_executors():
|
||||
executor3 = StringExecutor(id="executor3") # This will be isolated
|
||||
|
||||
# Create edges that include an isolated executor (self-loop that's not connected to main graph)
|
||||
edges = [Edge(executor1, executor2), Edge(executor3, executor3)] # Self-loop to include in graph
|
||||
edge_groups = [
|
||||
SingleEdgeGroup(executor1, executor2),
|
||||
SingleEdgeGroup(executor3, executor3),
|
||||
] # Self-loop to include in graph
|
||||
|
||||
with pytest.raises(GraphConnectivityError) as exc_info:
|
||||
validate_workflow_graph(edges, executor1)
|
||||
validate_workflow_graph(edge_groups, executor1)
|
||||
|
||||
assert "unreachable" in str(exc_info.value).lower()
|
||||
assert "executor3" in str(exc_info.value)
|
||||
@@ -239,15 +242,15 @@ def test_type_compatibility_inheritance():
|
||||
def test_direct_validation_function():
|
||||
executor1 = StringExecutor(id="executor1")
|
||||
executor2 = StringExecutor(id="executor2")
|
||||
edges = [Edge(executor1, executor2)]
|
||||
edge_groups = [SingleEdgeGroup(executor1, executor2)]
|
||||
|
||||
# This should not raise any exceptions
|
||||
validate_workflow_graph(edges, executor1)
|
||||
validate_workflow_graph(edge_groups, executor1)
|
||||
|
||||
# Test with invalid start executor
|
||||
executor3 = StringExecutor(id="executor3")
|
||||
with pytest.raises(GraphConnectivityError):
|
||||
validate_workflow_graph(edges, executor3)
|
||||
validate_workflow_graph(edge_groups, executor3)
|
||||
|
||||
|
||||
def test_fan_out_validation():
|
||||
|
||||
Reference in New Issue
Block a user