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
@@ -6,7 +6,7 @@ from dataclasses import dataclass
|
||||
import pytest
|
||||
from agent_framework.workflow import Executor, WorkflowCompletedEvent, WorkflowContext, WorkflowEvent, handler
|
||||
|
||||
from agent_framework_workflow._edge import Edge
|
||||
from agent_framework_workflow._edge import SingleEdgeGroup
|
||||
from agent_framework_workflow._runner import Runner
|
||||
from agent_framework_workflow._runner_context import InProcRunnerContext, RunnerContext
|
||||
from agent_framework_workflow._shared_state import SharedState
|
||||
@@ -36,12 +36,12 @@ def test_create_runner():
|
||||
executor_b = MockExecutor(id="executor_b")
|
||||
|
||||
# Create a loop
|
||||
edges = [
|
||||
Edge(source=executor_a, target=executor_b),
|
||||
Edge(source=executor_b, target=executor_a),
|
||||
edge_groups = [
|
||||
SingleEdgeGroup(executor_a, executor_b),
|
||||
SingleEdgeGroup(executor_b, executor_a),
|
||||
]
|
||||
|
||||
runner = Runner(edges, shared_state=SharedState(), ctx=InProcRunnerContext())
|
||||
runner = Runner(edge_groups, shared_state=SharedState(), ctx=InProcRunnerContext())
|
||||
|
||||
assert runner.context is not None and isinstance(runner.context, RunnerContext)
|
||||
|
||||
@@ -53,8 +53,8 @@ async def test_runner_run_until_convergence():
|
||||
|
||||
# Create a loop
|
||||
edges = [
|
||||
Edge(source=executor_a, target=executor_b),
|
||||
Edge(source=executor_b, target=executor_a),
|
||||
SingleEdgeGroup(executor_a, executor_b),
|
||||
SingleEdgeGroup(executor_b, executor_a),
|
||||
]
|
||||
|
||||
shared_state = SharedState()
|
||||
@@ -87,8 +87,8 @@ async def test_runner_run_until_convergence_not_completed():
|
||||
|
||||
# Create a loop
|
||||
edges = [
|
||||
Edge(source=executor_a, target=executor_b),
|
||||
Edge(source=executor_b, target=executor_a),
|
||||
SingleEdgeGroup(executor_a, executor_b),
|
||||
SingleEdgeGroup(executor_b, executor_a),
|
||||
]
|
||||
|
||||
shared_state = SharedState()
|
||||
@@ -117,8 +117,8 @@ async def test_runner_already_running():
|
||||
|
||||
# Create a loop
|
||||
edges = [
|
||||
Edge(source=executor_a, target=executor_b),
|
||||
Edge(source=executor_b, target=executor_a),
|
||||
SingleEdgeGroup(executor_a, executor_b),
|
||||
SingleEdgeGroup(executor_b, executor_a),
|
||||
]
|
||||
|
||||
shared_state = SharedState()
|
||||
|
||||
Reference in New Issue
Block a user