Skip to content

Commit 72b8b62

Browse files
committed
Rename WorkerPool -> Pool, better Pipeline validation, better Pipeline
flow tests.
1 parent f429083 commit 72b8b62

32 files changed

Lines changed: 611 additions & 514 deletions

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# `agentexec`
22

3-
[![codecov](https://codecov.io/gh/Agent-CI/agentexec/branch/main/graph/badge.svg)](https://codecov.io/gh/Agent-CI/agentexec)
3+
[![PyPI](https://img.shields.io/pypi/v/agentexec?color=blue)](https://pypi.org/project/agentexec/)
4+
[![Python](https://img.shields.io/badge/python-3.12+-blue)](https://www.python.org/)
5+
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
6+
[![Type Checked](https://img.shields.io/badge/type%20checked-ty-blue)](https://github.com/astral-sh/ty)
7+
[![Code Style](https://img.shields.io/badge/code%20style-ruff-orange)](https://github.com/astral-sh/ruff)
48

59
**Production-ready orchestration for OpenAI Agents SDK** with Redis-backed task queues, SQLAlchemy activity tracking, and multiprocessing worker pools.
610

@@ -38,7 +42,7 @@ uv add agentexec
3842
```
3943

4044
**Requirements:**
41-
- Python 3.11+
45+
- Python 3.12+
4246
- Redis (for task queue)
4347
- SQLAlchemy-compatible database (for activity tracking)
4448
- Agents that you want to parallelize!
@@ -68,7 +72,7 @@ class ResearchContext(BaseModel):
6872
engine = create_engine("sqlite:///agents.db")
6973

7074
# Create worker pool
71-
pool = ax.WorkerPool(engine=engine)
75+
pool = ax.Pool(engine=engine)
7276

7377

7478
@pool.task("research_company")
@@ -338,7 +342,7 @@ class MyContext(BaseModel):
338342
param: str
339343

340344

341-
pool = ax.WorkerPool(engine=engine)
345+
pool = ax.Pool(engine=engine)
342346

343347

344348
@pool.task("task_name")
@@ -435,7 +439,7 @@ ENV AGENTEXEC_WORKER_MODULE=src.worker
435439
import os
436440
import agentexec as ax
437441

438-
pool = ax.WorkerPool(database_url=os.environ["DATABASE_URL"])
442+
pool = ax.Pool(database_url=os.environ["DATABASE_URL"])
439443

440444
@pool.task("my_task")
441445
async def my_task(agent_id, context):
@@ -472,7 +476,7 @@ uv sync
472476
uv run pytest
473477

474478
# Type checking
475-
uv run mypy src/agentexec
479+
uv run ty check
476480

477481
# Linting
478482
uv run ruff check src/

docker/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Base Docker image for deploying agentexec workers.
1111
import os
1212
import agentexec as ax
1313

14-
pool = ax.WorkerPool(database_url=os.environ["DATABASE_URL"])
14+
pool = ax.Pool(database_url=os.environ["DATABASE_URL"])
1515

1616
@pool.task("my_task")
1717
async def my_task(agent_id, context):
@@ -71,13 +71,13 @@ Your worker module must expose either:
7171

7272
1. A `pool` variable (recommended):
7373
```python
74-
pool = ax.WorkerPool(database_url=os.environ["DATABASE_URL"])
74+
pool = ax.Pool(database_url=os.environ["DATABASE_URL"])
7575
```
7676

7777
2. Or a `create_pool()` function:
7878
```python
7979
def create_pool():
80-
return ax.WorkerPool(database_url=os.environ["DATABASE_URL"])
80+
return ax.Pool(database_url=os.environ["DATABASE_URL"])
8181
```
8282

8383
## Docker Compose Example

docker/entrypoint.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""Worker entrypoint for agentexec Docker container.
33
44
This script dynamically imports the user's worker module and starts the pool.
5-
The module must expose a `pool` variable (WorkerPool instance) or a
5+
The module must expose a `pool` variable (Pool instance) or a
66
`create_pool()` function that returns one.
77
88
Environment Variables:
@@ -21,12 +21,12 @@
2121

2222

2323
def get_pool():
24-
"""Import user module and extract the WorkerPool instance."""
24+
"""Import user module and extract the Pool instance."""
2525
module_path = os.environ.get("AGENTEXEC_WORKER_MODULE")
2626

2727
if not module_path:
2828
print("Error: AGENTEXEC_WORKER_MODULE environment variable is required")
29-
print("Set it to your Python module containing the WorkerPool instance")
29+
print("Set it to your Python module containing the Pool instance")
3030
print("Example: AGENTEXEC_WORKER_MODULE=myapp.worker")
3131
sys.exit(1)
3232

@@ -54,7 +54,7 @@ def get_pool():
5454
else:
5555
print(f"Error: Module '{module_path}' must expose 'pool' or 'create_pool()'")
5656
print("Example:")
57-
print(" pool = ax.WorkerPool(database_url=os.environ['DATABASE_URL'])")
57+
print(" pool = ax.Pool(database_url=os.environ['DATABASE_URL'])")
5858
sys.exit(1)
5959

6060
return pool

docs/api-reference/core.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ax.get_result()
1616
ax.Priority
1717

1818
# Worker
19-
ax.WorkerPool
19+
ax.Pool
2020

2121
# Activity
2222
ax.activity
@@ -235,12 +235,12 @@ Execute the task handler (called by workers).
235235

236236
---
237237

238-
## WorkerPool
238+
## Pool
239239

240240
Manages multi-process worker execution.
241241

242242
```python
243-
class WorkerPool:
243+
class Pool:
244244
def __init__(
245245
self,
246246
engine: Engine,
@@ -315,7 +315,7 @@ import agentexec as ax
315315
engine = create_engine("sqlite:///agents.db")
316316
ax.Base.metadata.create_all(engine)
317317

318-
pool = ax.WorkerPool(
318+
pool = ax.Pool(
319319
engine=engine,
320320
database_url="sqlite:///agents.db"
321321
)

docs/api-reference/pipeline.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ Orchestrates multi-step task workflows.
88

99
```python
1010
class Pipeline:
11-
def __init__(self, pool: WorkerPool)
11+
def __init__(self, pool: Pool)
1212
```
1313

1414
### Parameters
1515

1616
| Parameter | Type | Description |
1717
|-----------|------|-------------|
18-
| `pool` | `WorkerPool` | Worker pool for task registration and enqueueing |
18+
| `pool` | `Pool` | Worker pool for task registration and enqueueing |
1919

2020
### Example
2121

2222
```python
2323
import agentexec as ax
2424

25-
pool = ax.WorkerPool(database_url="sqlite:///agents.db")
25+
pool = ax.Pool(database_url="sqlite:///agents.db")
2626
pipeline = ax.Pipeline(pool)
2727

2828
class MyPipeline(pipeline.Base):
@@ -352,7 +352,7 @@ class ReportContext(BaseModel):
352352
format: str
353353
354354
# Create pool and pipeline
355-
pool = ax.WorkerPool(database_url="sqlite:///agents.db")
355+
pool = ax.Pool(database_url="sqlite:///agents.db")
356356
pipeline = ax.Pipeline(pool)
357357
358358
class ResearchPipeline(pipeline.Base):

docs/concepts/architecture.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Redis provides atomic operations, persistence options, and excellent performance
5050
The worker pool manages multiple Python processes:
5151

5252
```python
53-
pool = ax.WorkerPool(engine=engine, database_url=DATABASE_URL)
53+
pool = ax.Pool(engine=engine, database_url=DATABASE_URL)
5454

5555
@pool.task("my_task")
5656
async def my_task(agent_id: UUID, context: MyContext):
@@ -256,10 +256,10 @@ Use multiple queues for different workloads:
256256

257257
```python
258258
# High-priority pool
259-
pool_high = ax.WorkerPool(queue_name="high_priority", ...)
259+
pool_high = ax.Pool(queue_name="high_priority", ...)
260260

261261
# Low-priority pool
262-
pool_low = ax.WorkerPool(queue_name="low_priority", ...)
262+
pool_low = ax.Pool(queue_name="low_priority", ...)
263263

264264
# Enqueue to specific queue
265265
await ax.enqueue("urgent_task", ctx, queue_name="high_priority")

docs/concepts/task-lifecycle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class MyContext(BaseModel):
100100
company: str
101101
priority: int = 1
102102

103-
pool = ax.WorkerPool(engine=engine, database_url=DATABASE_URL)
103+
pool = ax.Pool(engine=engine, database_url=DATABASE_URL)
104104

105105
@pool.task("research_company")
106106
async def research_company(agent_id: UUID, context: MyContext) -> str:

docs/concepts/worker-pool.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The worker pool is the execution engine of agentexec. It manages multiple Python
66

77
```
88
┌─────────────────────────────────────────────────────────┐
9-
WorkerPool
9+
Pool
1010
│ ┌─────────────────────────────────────────────────┐ │
1111
│ │ Main Process │ │
1212
│ │ • Spawns worker processes │ │
@@ -39,7 +39,7 @@ engine = create_engine("postgresql://user:pass@localhost/mydb")
3939
ax.Base.metadata.create_all(engine)
4040

4141
# Create worker pool
42-
pool = ax.WorkerPool(
42+
pool = ax.Pool(
4343
engine=engine,
4444
database_url="postgresql://user:pass@localhost/mydb",
4545
queue_name=None, # Uses CONF.queue_name by default
@@ -351,7 +351,7 @@ Run multiple pools for different workloads:
351351

352352
```python
353353
# High-priority tasks
354-
pool_high = ax.WorkerPool(
354+
pool_high = ax.Pool(
355355
engine=engine,
356356
database_url=DATABASE_URL,
357357
queue_name="high_priority",
@@ -362,7 +362,7 @@ async def urgent_task(agent_id: UUID, context: UrgentContext):
362362
...
363363

364364
# Low-priority tasks
365-
pool_low = ax.WorkerPool(
365+
pool_low = ax.Pool(
366366
engine=engine,
367367
database_url=DATABASE_URL,
368368
queue_name="low_priority",

docs/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Use clear, descriptive commit messages:
177177
feat: add support for custom queue names
178178
179179
- Allow specifying queue_name in enqueue()
180-
- Update WorkerPool to accept queue_name parameter
180+
- Update Pool to accept queue_name parameter
181181
- Add tests for custom queue functionality
182182
```
183183

docs/getting-started/configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ These settings must be provided - there are no defaults:
2828
|----------|-------------|---------|
2929
| `REDIS_URL` or `AGENTEXEC_REDIS_URL` | Redis connection URL | `redis://localhost:6379/0` |
3030

31-
The `DATABASE_URL` is passed directly to `WorkerPool`, not through configuration.
31+
The `DATABASE_URL` is passed directly to `Pool`, not through configuration.
3232

3333
## Optional Settings
3434

@@ -127,7 +127,7 @@ Create a `.env` file in your project root:
127127
# Required
128128
REDIS_URL=redis://localhost:6379/0
129129

130-
# Database (passed to WorkerPool)
130+
# Database (passed to Pool)
131131
DATABASE_URL=postgresql://user:password@localhost:5432/myapp
132132

133133
# OpenAI (for agents)
@@ -269,7 +269,7 @@ REDIS_URL=rediss://localhost:6379/0
269269

270270
## Database URL Format
271271

272-
The `DATABASE_URL` passed to `WorkerPool` follows SQLAlchemy conventions:
272+
The `DATABASE_URL` passed to `Pool` follows SQLAlchemy conventions:
273273

274274
```bash
275275
# PostgreSQL

0 commit comments

Comments
 (0)