|
1 | 1 | """Components for managing tasks within the A2A server.""" |
2 | 2 |
|
| 3 | +import logging |
| 4 | + |
3 | 5 | from a2a.server.tasks.base_push_notification_sender import ( |
4 | 6 | BasePushNotificationSender, |
5 | 7 | ) |
6 | 8 | from a2a.server.tasks.database_push_notification_config_store import ( |
7 | 9 | DatabasePushNotificationConfigStore, |
8 | 10 | ) |
9 | | -from a2a.server.tasks.database_task_store import DatabaseTaskStore |
10 | 11 | from a2a.server.tasks.inmemory_push_notification_config_store import ( |
11 | 12 | InMemoryPushNotificationConfigStore, |
12 | 13 | ) |
|
21 | 22 | from a2a.server.tasks.task_updater import TaskUpdater |
22 | 23 |
|
23 | 24 |
|
| 25 | +logger = logging.getLogger(__name__) |
| 26 | + |
| 27 | +try: |
| 28 | + from a2a.server.tasks.database_task_store import ( |
| 29 | + DatabaseTaskStore, # type: ignore |
| 30 | + ) |
| 31 | +except ImportError as e: |
| 32 | + _original_error = e |
| 33 | + # If the database task store is not available, we can still use in-memory stores. |
| 34 | + logger.debug( |
| 35 | + 'DatabaseTaskStore not loaded. This is expected if database dependencies are not installed. Error: %s', |
| 36 | + e, |
| 37 | + ) |
| 38 | + |
| 39 | + class DatabaseTaskStore: # type: ignore |
| 40 | + """Placeholder for DatabaseTaskStore when dependencies are not installed.""" |
| 41 | + |
| 42 | + def __init__(self, *args, **kwargs): |
| 43 | + raise ImportError( |
| 44 | + 'To use DatabaseTaskStore, its dependencies must be installed. ' |
| 45 | + 'You can install them with \'pip install "a2a-sdk[sql]"\'' |
| 46 | + ) from _original_error |
| 47 | + |
| 48 | + |
24 | 49 | __all__ = [ |
25 | 50 | 'BasePushNotificationSender', |
26 | 51 | 'DatabasePushNotificationConfigStore', |
|
0 commit comments