Skip to content

Commit 49b2f16

Browse files
authored
Merge pull request #15 from agntcy/PUCCINI-270
Add unit tests covering basic features
2 parents aa8fe36 + 63fda1f commit 49b2f16

26 files changed

+600
-257
lines changed

Diff for: .env.example

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
# POETRY ENV
2-
POETRY_VIRTUALENVS_IN_PROJECT=true
3-
41
### SERVER-SPECIFIC ENV ###
52
API_HOST=127.0.0.1
63
API_PORT=8000
74
AGENTS_REF='{"agent_name": "agent_module_name:agent_var"}'
85
AGENT_MANIFEST_PATH=manifest.json
6+
AGWS_STORAGE_PERSIST=True
97
AGWS_STORAGE_PATH=agws_storage.pkl
108
NUM_WORKERS=5
119
API_KEY=your-secret-key-here

Diff for: .vscode/settings.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"python.testing.pytestArgs": [
3+
"tests"
4+
],
5+
"python.testing.unittestEnabled": false,
6+
"python.testing.pytestEnabled": true,
7+
"[python]": {
8+
"editor.formatOnSave": true,
9+
"editor.defaultFormatter": "charliermarsh.ruff",
10+
"editor.codeActionsOnSave": {
11+
"source.fixAll": "explicit"
12+
}
13+
}
14+
}

Diff for: Makefile

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PACKAGE_NAME := agent_workflow_server.generated
77
GENERATOR_IMAGE := openapitools/openapi-generator-cli:latest
88
ADDITIONAL_PROPERTIES := packageName=$(PACKAGE_NAME),python_typed=true
99

10-
.PHONY: clean validate-spec update-spec generate-api run docker-build-dev
10+
.PHONY: clean validate-spec update-spec generate-api run docker-build-dev test format lint lint-fix
1111

1212
# Ensure output directory exists
1313
$(OUTPUT_DIR):
@@ -46,5 +46,17 @@ run:
4646
poetry install
4747
poetry run server
4848

49+
test:
50+
poetry run pytest
51+
52+
format:
53+
poetry run ruff format .
54+
55+
lint:
56+
poetry run ruff check .
57+
58+
lint-fix:
59+
poetry run ruff check . --fix
60+
4961
docker-build-dev: ## Build the docker image.
5062
docker buildx bake workflowserver-dev --load

Diff for: poetry.lock

+118-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: poetry.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[virtualenvs]
2+
in-project = true

Diff for: pyproject.toml

+25-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,35 @@ dependencies = [
1515
"uvicorn (>=0.34.0,<0.35.0)",
1616
"langgraph (>=0.2.60,<0.4.0)",
1717
"llama-index (>=0.12.0,<0.13.0)",
18-
"dotenv (>=0.9.9,<0.10.0)"
18+
"dotenv (>=0.9.9,<0.10.0)",
1919
]
2020

2121
[build-system]
2222
requires = ["poetry-core>=2.0.0,<3.0.0"]
2323
build-backend = "poetry.core.masonry.api"
2424

2525
[tool.poetry.scripts]
26-
server = "agent_workflow_server.main:start"
26+
server = "agent_workflow_server.main:start"
27+
28+
[tool.poetry.group.dev.dependencies]
29+
pytest = "^8.3.5"
30+
pytest-mock = "^3.14.0"
31+
ruff = "^0.11.0"
32+
pytest-asyncio = "^0.25.3"
33+
34+
[tool.ruff]
35+
lint.select = [ "E", "F", "I", "TID251"]
36+
lint.ignore = [ "E501" ]
37+
indent-width = 4
38+
exclude = ["src/agent_workflow_server/generated/*"]
39+
40+
[tool.ruff.format]
41+
quote-style = "double"
42+
indent-style = "space"
43+
44+
[tool.pytest.ini_options]
45+
minversion = "6.0"
46+
testpaths = [
47+
"tests"
48+
]
49+
asyncio_default_fixture_loop_scope="function"

Diff for: src/agent_workflow_server/agents/adapters/langgraph.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from typing import Optional
2+
23
from langgraph.graph.graph import CompiledGraph, Graph
34

4-
from agent_workflow_server.agents.base import BaseAgent, BaseAdapter
5+
from agent_workflow_server.agents.base import BaseAdapter, BaseAgent
56

67

78
class LangGraphAdapter(BaseAdapter):
@@ -18,5 +19,7 @@ def __init__(self, agent: CompiledGraph):
1819
self.agent = agent
1920

2021
async def astream(self, input: dict, config: dict):
21-
async for event in self.agent.astream(input=input, config=config, stream_mode="values"):
22+
async for event in self.agent.astream(
23+
input=input, config=config, stream_mode="values"
24+
):
2225
yield event

Diff for: src/agent_workflow_server/agents/adapters/llamaindex.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import inspect
12
from typing import Optional
3+
24
from llama_index.core.workflow import Workflow
3-
from agent_workflow_server.agents.base import BaseAgent, BaseAdapter
4-
import inspect
5+
6+
from agent_workflow_server.agents.base import BaseAdapter, BaseAgent
7+
58

69
class LlamaIndexAdapter(BaseAdapter):
710
def load_agent(self, agent: object) -> Optional[BaseAgent]:

Diff for: src/agent_workflow_server/agents/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from abc import ABC, abstractmethod
2-
from typing import AsyncGenerator, Optional, Any
2+
from typing import Any, AsyncGenerator, Optional
33

44

55
class BaseAgent(ABC):

0 commit comments

Comments
 (0)