|
5 | 5 | from a2a.server.tasks.base_push_notification_sender import ( |
6 | 6 | BasePushNotificationSender, |
7 | 7 | ) |
8 | | -from a2a.server.tasks.database_push_notification_config_store import ( |
9 | | - DatabasePushNotificationConfigStore, |
10 | | -) |
11 | 8 | from a2a.server.tasks.inmemory_push_notification_config_store import ( |
12 | 9 | InMemoryPushNotificationConfigStore, |
13 | 10 | ) |
@@ -46,6 +43,28 @@ def __init__(self, *args, **kwargs): |
46 | 43 | ) from _original_error |
47 | 44 |
|
48 | 45 |
|
| 46 | +try: |
| 47 | + from a2a.server.tasks.database_push_notification_config_store import ( |
| 48 | + DatabasePushNotificationConfigStore, # type: ignore |
| 49 | + ) |
| 50 | +except ImportError as e: |
| 51 | + _original_error = e |
| 52 | + # If the database push notification config store is not available, we can still use in-memory stores. |
| 53 | + logger.debug( |
| 54 | + 'DatabasePushNotificationConfigStore not loaded. This is expected if database dependencies are not installed. Error: %s', |
| 55 | + e, |
| 56 | + ) |
| 57 | + |
| 58 | + class DatabasePushNotificationConfigStore: # type: ignore |
| 59 | + """Placeholder for DatabasePushNotificationConfigStore when dependencies are not installed.""" |
| 60 | + |
| 61 | + def __init__(self, *args, **kwargs): |
| 62 | + raise ImportError( |
| 63 | + 'To use DatabasePushNotificationConfigStore, its dependencies must be installed. ' |
| 64 | + 'You can install them with \'pip install "a2a-sdk[sql]"\'' |
| 65 | + ) from _original_error |
| 66 | + |
| 67 | + |
49 | 68 | __all__ = [ |
50 | 69 | 'BasePushNotificationSender', |
51 | 70 | 'DatabasePushNotificationConfigStore', |
|
0 commit comments