mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Move Workflow, Edge, EdgeGroup and Executor to AFBaseModel (#472)
* Refactor workflow to introduce EdgeRunner for edge execution. * Fix edge cases * Convert Workflow, Edge, EdgeGroup, and Executor into AFBaseModel to support object model serialization * format * remove accidental file * fix typing * Add type information to EdgeGroup and Executor subclasses * fix format * Add condition_name field to Edge * Add new fields * remove Optional * Update
This commit is contained in:
committed by
GitHub
Unverified
parent
88c51013c6
commit
6e9d35830f
@@ -37,11 +37,13 @@ def test_create_runner():
|
||||
|
||||
# Create a loop
|
||||
edge_groups = [
|
||||
SingleEdgeGroup(executor_a, executor_b),
|
||||
SingleEdgeGroup(executor_b, executor_a),
|
||||
SingleEdgeGroup(executor_a.id, executor_b.id),
|
||||
SingleEdgeGroup(executor_b.id, executor_a.id),
|
||||
]
|
||||
|
||||
runner = Runner(edge_groups, shared_state=SharedState(), ctx=InProcRunnerContext())
|
||||
executors: dict[str, Executor] = {executor_a.id: executor_a, executor_b.id: executor_b}
|
||||
|
||||
runner = Runner(edge_groups, executors, shared_state=SharedState(), ctx=InProcRunnerContext())
|
||||
|
||||
assert runner.context is not None and isinstance(runner.context, RunnerContext)
|
||||
|
||||
@@ -53,14 +55,15 @@ async def test_runner_run_until_convergence():
|
||||
|
||||
# Create a loop
|
||||
edges = [
|
||||
SingleEdgeGroup(executor_a, executor_b),
|
||||
SingleEdgeGroup(executor_b, executor_a),
|
||||
SingleEdgeGroup(executor_a.id, executor_b.id),
|
||||
SingleEdgeGroup(executor_b.id, executor_a.id),
|
||||
]
|
||||
|
||||
executors: dict[str, Executor] = {executor_a.id: executor_a, executor_b.id: executor_b}
|
||||
shared_state = SharedState()
|
||||
ctx = InProcRunnerContext()
|
||||
|
||||
runner = Runner(edges, shared_state, ctx)
|
||||
runner = Runner(edges, executors, shared_state, ctx)
|
||||
|
||||
result: int | None = None
|
||||
await executor_a.execute(
|
||||
@@ -87,14 +90,15 @@ async def test_runner_run_until_convergence_not_completed():
|
||||
|
||||
# Create a loop
|
||||
edges = [
|
||||
SingleEdgeGroup(executor_a, executor_b),
|
||||
SingleEdgeGroup(executor_b, executor_a),
|
||||
SingleEdgeGroup(executor_a.id, executor_b.id),
|
||||
SingleEdgeGroup(executor_b.id, executor_a.id),
|
||||
]
|
||||
|
||||
executors: dict[str, Executor] = {executor_a.id: executor_a, executor_b.id: executor_b}
|
||||
shared_state = SharedState()
|
||||
ctx = InProcRunnerContext()
|
||||
|
||||
runner = Runner(edges, shared_state, ctx, max_iterations=5)
|
||||
runner = Runner(edges, executors, shared_state, ctx, max_iterations=5)
|
||||
|
||||
await executor_a.execute(
|
||||
MockMessage(data=0),
|
||||
@@ -117,14 +121,15 @@ async def test_runner_already_running():
|
||||
|
||||
# Create a loop
|
||||
edges = [
|
||||
SingleEdgeGroup(executor_a, executor_b),
|
||||
SingleEdgeGroup(executor_b, executor_a),
|
||||
SingleEdgeGroup(executor_a.id, executor_b.id),
|
||||
SingleEdgeGroup(executor_b.id, executor_a.id),
|
||||
]
|
||||
|
||||
executors: dict[str, Executor] = {executor_a.id: executor_a, executor_b.id: executor_b}
|
||||
shared_state = SharedState()
|
||||
ctx = InProcRunnerContext()
|
||||
|
||||
runner = Runner(edges, shared_state, ctx)
|
||||
runner = Runner(edges, executors, shared_state, ctx)
|
||||
|
||||
await executor_a.execute(
|
||||
MockMessage(data=0),
|
||||
|
||||
Reference in New Issue
Block a user