Skip to content

Commit 2126828

Browse files
authored
fix: Resolve dependency issue with sql stores (#303)
1 parent 0274112 commit 2126828

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/a2a/server/tasks/__init__.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""Components for managing tasks within the A2A server."""
22

3+
import logging
4+
35
from a2a.server.tasks.base_push_notification_sender import (
46
BasePushNotificationSender,
57
)
6-
from a2a.server.tasks.database_task_store import DatabaseTaskStore
78
from a2a.server.tasks.inmemory_push_notification_config_store import (
89
InMemoryPushNotificationConfigStore,
910
)
@@ -18,6 +19,30 @@
1819
from a2a.server.tasks.task_updater import TaskUpdater
1920

2021

22+
logger = logging.getLogger(__name__)
23+
24+
try:
25+
from a2a.server.tasks.database_task_store import (
26+
DatabaseTaskStore, # type: ignore
27+
)
28+
except ImportError as e:
29+
_original_error = e
30+
# If the database task store is not available, we can still use in-memory stores.
31+
logger.debug(
32+
'DatabaseTaskStore not loaded. This is expected if database dependencies are not installed. Error: %s',
33+
e,
34+
)
35+
36+
class DatabaseTaskStore: # type: ignore
37+
"""Placeholder for DatabaseTaskStore when dependencies are not installed."""
38+
39+
def __init__(self, *args, **kwargs):
40+
raise ImportError(
41+
'To use DatabaseTaskStore, its dependencies must be installed. '
42+
'You can install them with \'pip install "a2a-sdk[sql]"\''
43+
) from _original_error
44+
45+
2146
__all__ = [
2247
'BasePushNotificationSender',
2348
'DatabaseTaskStore',

0 commit comments

Comments
 (0)