-
Notifications
You must be signed in to change notification settings - Fork 80
feat(db): support multiple SQL backends with optional extras (cont. #80) #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit replaces the PostgreSQL-specific TaskStore with a generic `DatabaseTaskStore` that leverages SQLAlchemy for database interactions. This change allows your A2A server to support multiple database backends, including SQLite, PostgreSQL, and MySQL. Key changes include: - Definition of a SQLAlchemy model `TaskModel` for storing task data. - Implementation of `DatabaseTaskStore` that uses the `TaskStore` interface and SQLAlchemy for CRUD operations. - Update of example application configurations to use `DatabaseTaskStore` when a `DATABASE_URL` environment variable is provided, defaulting to `InMemoryTaskStore` otherwise. - Creation of parameterized unit tests for `DatabaseTaskStore`, designed to run against SQLite, PostgreSQL, and MySQL to ensure compatibility. - Removal of the old `PostgreSQLTaskStore` and its specific tests. - Addition of necessary dependencies: `sqlalchemy`, `aiosqlite`, `aiomysql`. The new implementation makes the task persistence layer more flexible and extensible, allowing you to choose a database backend that best suits your needs.
This commit replaces the PostgreSQL-specific TaskStore with a generic `DatabaseTaskStore` that leverages SQLAlchemy for database interactions. This change allows your A2A server to support multiple database backends, including SQLite, PostgreSQL, and MySQL. Key changes include: - Definition of a SQLAlchemy model `TaskModel` for storing task data. - Implementation of `DatabaseTaskStore` that uses the `TaskStore` interface and SQLAlchemy for CRUD operations. - Update of example application configurations to use `DatabaseTaskStore` when a `DATABASE_URL` environment variable is provided, defaulting to `InMemoryTaskStore` otherwise. - Creation of parameterized unit tests for `DatabaseTaskStore`, designed to run against SQLite, PostgreSQL, and MySQL to ensure compatibility. - Removal of the old `PostgreSQLTaskStore` and its specific tests. - Addition of necessary dependencies: `sqlalchemy`, `aiosqlite`, `aiomysql`. The new implementation makes the task persistence layer more flexible and extensible, allowing you to choose a database backend that best suits your needs.
This commit introduces optional dependencies for PostgreSQL, MySQL, and SQLite support in the A2A SDK. Key changes include: - Addition of optional dependencies in `pyproject.toml` for database drivers. - Updates to example applications to demonstrate installation and usage with different databases. - Refactoring of task management to utilize a generic `DatabaseTaskStore` for improved flexibility. - Enhancements to the README for clearer instructions on database support. These changes enhance the SDK's versatility, allowing users to choose their preferred database backend.
…he spelling action
… gracefully skip when SQLAlchemy isn't installed locally
Can you please move the changes to the sample agents to the new samples repo? https://github.com/google-a2a/a2a-samples |
@zboyles thanks for the PR. Few comments:
I will merge this PR to a new branch so change required for database based PushNotifier and common db connection are done and then will merge into main. |
This allows users to choose their preferred database backend (PostgreSQL, MySQL, SQLite) while maintaining full compatibility and proper type safety. - Replace PostgreSQL-specific JSONB with generic JSON type in models - Implement SQLAlchemy 2.0 best practices with Mapped types and TypeDecorator - Add configurable table name support via create_task_model() factory - Updated metadata field mapping between Pydantic and SQLAlchemy using declared_attr - Add comprehensive tests for metadata field mapping including complex nested data - Update GitHub Actions to install SQL dependencies for tests - Add pytest.importorskip to gracefully skip database tests when SQLAlchemy not installed - Fix test_types.py to use 'id' instead of 'taskId' for JSON-RPC requests - Add automatic cleanup of SQLite file::memory: files after tests - Remove examples directory (moved to separate a2a-samples repo) - Update pyproject.toml to remove workspace members reference and add `nox` for testing
- Update repository reference to google-a2a/a2a-python - Keep PostgreSQL service configuration for tests - Regenerate uv.lock to resolve dependency conflicts
Thanks @holtskinner and @kthota-g.
|
…patibility The override decorator was added in Python 3.12. For compatibility with Python 3.10, we import it from typing_extensions when not available in the typing module.
Thanks for the changes. I will merge this PR into a |
What’s changed
DatabaseTaskStore
interfacepyproject.toml
for database drivers:a2a-sdk[postgresql]
a2a-sdk[mysql]
a2a-sdk[sqlite]
a2a-sdk[sql]
Why
Per @kthota-g’s feedback (#80 (comment)), making the SDK database-agnostic increases flexibility and broadens adoption.
Testing
pytest
andnox
locallyNotes
Please focus review on: interface design/naming, optional-extra configuration, test coverage, and real-world usage scenarios.