Skip to content

Commit afee56f

Browse files
committed
chore: use pytest to run examples
1 parent 4284b2d commit afee56f

File tree

6 files changed

+47
-13
lines changed

6 files changed

+47
-13
lines changed

.github/workflows/examples.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
push:
44
branches:
55
- main
6+
- guillaume/fix-examples-ga
67
schedule:
78
# Every night at midnight
89
- cron: "0 0 * * *"
@@ -27,16 +28,7 @@ jobs:
2728
run: poetry install --all-extras
2829

2930
- name: Run all example scripts
30-
run: |
31-
# Find all Python files in examples directory
32-
find examples -name "*.py" -type f | while read -r script; do
33-
echo "Running example: $script"
34-
poetry run python "$script"
35-
if [ $? -ne 0 ]; then
36-
echo "Error: Failed to run $script"
37-
exit 1
38-
fi
39-
done
31+
run: make test.examples
4032
env:
4133
WORKFLOWAI_API_KEY: ${{ secrets.WORKFLOWAI_TEST_API_KEY }}
4234

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ test:
3131
.PHONY: lock
3232
lock:
3333
poetry lock --no-update
34+
35+
test.examples:
36+
poetry run pytest examples -n=5

examples/17_multi_model_consensus_with_tools.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import asyncio
2222

23+
import pytest
2324
from pydantic import BaseModel, Field
2425

2526
import workflowai
@@ -131,6 +132,7 @@ async def combine_responses(responses_input: CombinerInput) -> CombinedOutput:
131132
...
132133

133134

135+
@pytest.mark.xfail(reason="Example is flaky")
134136
async def main():
135137
# Example: Scientific explanation
136138
print("\nExample: Scientific Concept")

examples/workflows/agent_delegation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import asyncio
1818
from typing import Optional
1919

20+
import pytest
2021
from pydantic import BaseModel, Field
2122

2223
import workflowai
@@ -118,7 +119,7 @@ async def delegate_task(agent_input: DelegateInput) -> DelegateOutput:
118119

119120
@workflowai.agent(
120121
id="orchestrator",
121-
model=Model.GPT_4O_LATEST,
122+
model=Model.GEMINI_2_0_FLASH_LATEST,
122123
tools=[delegate_task],
123124
)
124125
async def orchestrator_agent(agent_input: OrchestratorInput) -> OrchestratorOutput:
@@ -148,6 +149,7 @@ async def orchestrator_agent(agent_input: OrchestratorInput) -> OrchestratorOutp
148149
...
149150

150151

152+
@pytest.mark.xfail(reason="Example is flaky")
151153
async def main():
152154
# Example: Software architecture task
153155
print("\nExample: Software Architecture Design")

poetry.lock

Lines changed: 36 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ruff = "^0.9.6"
2020
freezegun = "^1.5.1"
2121
pre-commit = "^4.0.1"
2222
pytest-httpx = "^0.35.0"
23+
pytest-xdist = "^3.1.0"
2324
python-dotenv = "^1.0.1"
2425
typer = "^0.15.1"
2526
rich = "^13.7.1"

0 commit comments

Comments
 (0)