-
Notifications
You must be signed in to change notification settings - Fork 80
feat: Postgres task store #80
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Hi, Apart from Task Store, the InMemoryPushNotifier currently relies on an in-memory store as well and should also have a database backed store. It would be simpler if the configuration can allow sharing database connection between these two stores. lmk what you think. |
…) (#106) * feat: postgresql task store * feat: postgresql task store * feat: postgresql task store * feat: postgresql task store * feat: postgresql task store * Update check-spelling metadata * feat: postgresql task store * Refactor TaskStore to be database-agnostic using SQLAlchemy 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. * feat: postgresql task store * feat: postgresql task store * feat: postgresql task store * feat: postgresql task store * feat: postgresql task store * Update check-spelling metadata * feat: postgresql task store * Refactor TaskStore to be database-agnostic using SQLAlchemy 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. * Refactor project to support multiple database backends 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. * Add drivername, aiomysql, and DSNs to the list of expected words in the spelling action * GitHub Actions installs SQL dependencies for tests and database tests gracefully skip when SQLAlchemy isn't installed locally * feat(db): refactor database backend to be database-agnostic 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 * fix(models): correct variable name in TaskModel repr template * fix: use typing_extensions for override decorator for Python 3.10 compatibility 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. --------- Co-authored-by: MEUNIER Laurent <[email protected]> Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Zac <[email protected]> Co-authored-by: kthota-g <[email protected]>
Description
Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTING
Guide.nox -s format
from the repository root to format)Fixes #<issue_number_goes_here> 🦕