Skip to content

Commit

Permalink
chore(agents-api): add a test for parallelism check
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad-mtos committed Feb 14, 2025
1 parent c3b029f commit a65c811
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions agents-api/tests/test_workflow_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from agents_api.autogen.openapi_model import (
Agent,
MapReduceStep,
PromptItem,
PromptStep,
TaskSpecDef,
TransitionTarget,
Workflow,
Expand Down Expand Up @@ -66,3 +68,52 @@ async def _resp():
items=["1", "2", "3"],
current_input={},
)


@test("execute_map_reduce_step_parallel: parallelism must be greater than 1")
async def _():
async def _resp():
return "response"

subworkflow_step = PromptStep(prompt=[PromptItem(content="hi there", role="user")])

step = MapReduceStep(
kind_="map_reduce",
map=subworkflow_step,
over="$ [1, 2, 3]",
parallelism=1,
)

execution_input = ExecutionInput(
developer_id=uuid.uuid4(),
agent=Agent(
id=uuid.uuid4(), name="test agent", created_at=utcnow(), updated_at=utcnow()
),
agent_tools=[],
arguments={},
task=TaskSpecDef(
name="task1",
tools=[],
workflows=[Workflow(name="main", steps=[step])],
),
)

context = StepContext(
execution_input=execution_input,
current_input={"current_input": "value 1"},
cursor=TransitionTarget(
workflow="main",
step=0,
),
)
with patch("agents_api.workflows.task_execution.helpers.workflow") as workflow:
workflow.execute_activity.return_value = await _resp()
with raises(AssertionError):
await execute_map_reduce_step_parallel(
context=context,
map_defn=step.map,
execution_input=execution_input,
items=["1", "2", "3"],
current_input={},
parallelism=1,
)

0 comments on commit a65c811

Please sign in to comment.