This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Create virtual environment (using Python 3.13)
make venv
# Install dependencies
make install # Install main dependencies
make install-test # Install main and test dependencies# Run all tests
make test # This will also run linting
# Run specific test
pytest tests/path/to/test_file.py::TestClass::test_method
# Run tests with coverage
pytest --cov=agave# Format code
make format # Runs isort and black
# Lint code
make lint # Runs flake8, isort --check-only, black --check, mypy# Create distribution packages
make release # Runs tests, creates sdist and wheel, uploads to PyPIAgave is a Python library for building REST APIs using a Blueprint pattern with support for both AWS Chalice and FastAPI frameworks. It provides a consistent way to create JSON-based endpoints for querying, modifying, and creating resources.
-
Blueprint Pattern
RestApiBlueprintclasses for both Chalice and FastAPI- Standardized resource decorators that create CRUD endpoints
-
Framework Support
agave.chalice: Chalice-specific implementationagave.fastapi: FastAPI-specific implementation
-
Async Tasks
- SQS-based task processing system in
agave.tasks - Support for retries, error handling, and concurrency control
- SQS-based task processing system in
agave/core/: Core functionality shared between frameworksagave/chalice/: AWS Chalice specific implementationagave/fastapi/: FastAPI specific implementationagave/tasks/: Async task processing with SQSagave/tools/: Utilities for AWS services (sync and async)
-
Resource Blueprint
- Define a class with model, validation, and CRUD methods
- Apply
@app.resource('/path')decorator to generate standard endpoints - Customize behavior by implementing specific methods (create, update, delete, etc.)
-
Validation
- Uses Pydantic models for request/response validation
- Automatically handles validation errors and returns appropriate responses
-
MongoDB Integration
- Designed to work with MongoEngine for data persistence
- Uses
mongoengine_plus.aio.AsyncDocumentfor async MongoDB operations in FastAPI - Provides standardized query filtering and pagination
-
Asynchronous Support
- FastAPI implementation uses async/await pattern
- SQS tasks support async processing with concurrency control
- Define a model:
- For FastAPI: Use
mongoengine_plus.aio.AsyncDocumentfor async MongoDB operations - For Chalice: Use standard
mongoengine.Document
- For FastAPI: Use
- Create validation models (Pydantic)
- Define a Resource class with CRUD operations
- Apply
@app.resource('/path')decorator
- Import task decorator:
from agave.tasks.sqs_tasks import task - Define task function with Pydantic model type hints for automatic validation
- Apply
@task(queue_url=URL, region_name=REGION)decorator - Implement error handling with
raise RetryTask()pattern
Tasks automatically validate and parse incoming JSON messages into Pydantic models if type hints are provided:
from pydantic import BaseModel
from agave.tasks.sqs_tasks import task
class User(BaseModel):
name: str
age: int
@task(queue_url=QUEUE_URL, region_name='us-east-1')
async def process_user(user: User) -> None:
# 'user' is already a validated Pydantic model instance
print(user.name, user.age)- Use framework-specific error responses
- For SQS tasks, use
RetryTaskexception to trigger retry logic - All validation errors are automatically handled and return 400 responses