diaspora-event-sdk 0.0.9__py3-none-any.whl → 0.0.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,8 +10,7 @@ from diaspora_event_sdk.sdk.client import Client # Globus client
10
10
  from diaspora_event_sdk.sdk.kafka_client import kafka_available
11
11
 
12
12
  if kafka_available:
13
- from diaspora_event_sdk.sdk.kafka_client import KafkaProducer, KafkaConsumer, KafkaAdmin, NewTopic
14
- __all__ = ("Client", "KafkaProducer", "KafkaConsumer",
15
- "KafkaAdmin", "NewTopic")
13
+ from diaspora_event_sdk.sdk.kafka_client import KafkaProducer, KafkaConsumer
14
+ __all__ = ("Client", "KafkaProducer", "KafkaConsumer")
16
15
  else:
17
16
  __all__ = ("Client")
@@ -1,7 +1,7 @@
1
+ from typing import Optional
1
2
  import json
2
3
 
3
4
  from diaspora_event_sdk.sdk.login_manager import LoginManager, LoginManagerProtocol, requires_login
4
-
5
5
  from ._environments import TOKEN_EXCHANGE, DIASPORA_RESOURCE_SERVER
6
6
 
7
7
 
@@ -9,8 +9,8 @@ class Client:
9
9
 
10
10
  def __init__(
11
11
  self,
12
- environment: str | None = None,
13
- login_manager: LoginManagerProtocol | None = None,
12
+ environment: Optional[str] = None,
13
+ login_manager: Optional[LoginManagerProtocol] = None,
14
14
  ):
15
15
  # if a login manager was passed, no login flow is triggered
16
16
  if login_manager is not None:
@@ -8,8 +8,7 @@ from .client import Client
8
8
  # If kafka-python is not installed, Kafka functionality is not available through diaspora-event-sdk.
9
9
  kafka_available = True
10
10
  try:
11
- from kafka import KafkaProducer, KafkaConsumer, KafkaAdminClient
12
- from kafka.admin import NewTopic
11
+ from kafka import KafkaProducer, KafkaConsumer
13
12
  except ImportError:
14
13
  kafka_available = False
15
14
 
@@ -25,7 +24,7 @@ def get_diaspora_config(extra_configs: Dict[str, Any] = {}) -> Dict[str, Any]:
25
24
  raise RuntimeError("Failed to retrieve Kafka keys") from e
26
25
 
27
26
  conf = {
28
- "bootstrap_servers": MSK_SCRAM_ENDPOINT,
27
+ "bootstrap_servers": MSK_SCRAM_ENDPOINT,
29
28
  "security_protocol": "SASL_SSL",
30
29
  "sasl_mechanism": "SCRAM-SHA-512",
31
30
  "api_version": (3, 5, 1),
@@ -37,14 +36,12 @@ def get_diaspora_config(extra_configs: Dict[str, Any] = {}) -> Dict[str, Any]:
37
36
 
38
37
 
39
38
  if kafka_available:
40
- class KafkaAdmin(KafkaAdminClient):
41
- def __init__(self, **configs):
42
- super().__init__(**get_diaspora_config(configs))
43
39
 
44
40
  class KafkaProducer(KafkaProducer):
45
41
  def __init__(self, **configs):
46
- configs.setdefault("value_serializer",
47
- lambda v: json.dumps(v).encode('utf-8'))
42
+ configs.setdefault(
43
+ "value_serializer", lambda v: json.dumps(v).encode("utf-8")
44
+ )
48
45
  super().__init__(**get_diaspora_config(configs))
49
46
 
50
47
  class KafkaConsumer(KafkaConsumer):
@@ -1,8 +1,6 @@
1
-
2
- import typing as t
1
+ from typing import Optional
3
2
 
4
3
  import globus_sdk
5
- from globus_sdk.exc.api import GlobusAPIError
6
4
  from diaspora_event_sdk.sdk.utils.uuid_like import UUID_LIKE_T
7
5
 
8
6
  from ._environments import TOKEN_EXCHANGE
@@ -13,9 +11,9 @@ class WebClient(globus_sdk.BaseClient):
13
11
  def __init__(
14
12
  self,
15
13
  *,
16
- environment: t.Optional[str] = None,
17
- base_url: t.Optional[str] = None,
18
- app_name: t.Optional[str] = None,
14
+ environment: Optional[str] = None,
15
+ base_url: Optional[str] = None,
16
+ app_name: Optional[str] = None,
19
17
  **kwargs,
20
18
  ):
21
19
  if base_url is None:
@@ -1 +1 @@
1
- __version__ = "0.0.9"
1
+ __version__ = "0.0.11"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diaspora-event-sdk
3
- Version: 0.0.9
3
+ Version: 0.0.11
4
4
  Summary: SDK of Diaspora Event Fabric: Resilience-enabling services for science from HPC to edge
5
5
  Home-page: https://github.com/globus-labs/diaspora-event-sdk
6
6
  License: LICENSE
@@ -12,30 +12,32 @@ Requires-Dist: kafka-python ; extra == 'kafka-python'
12
12
 
13
13
  <h1>Diaspora Event Fabric: Resilience-enabling services for science from HPC to edge</h1>
14
14
 
15
- - [Installation Instructions](#installation-instructions)
16
- - [Recommended Installation with Kafka Client Library: kafka-python](#recommended-installation-with-kafka-client-library-kafka-python)
17
- - [Installation Without Kafka Client Library](#installation-without-kafka-client-library)
15
+ - [Installation](#installation)
16
+ * [Recommended Installation with Kafka Client Library](#recommended-installation-with-kafka-client-library)
17
+ * [Installation Without Kafka Client Library](#installation-without-kafka-client-library)
18
18
  - [Use Diaspora Event SDK](#use-diaspora-event-sdk)
19
- - [Use SDK to communicate with Kafka (kafka-python Required)](#use-sdk-to-communicate-with-kafka-kafka-python-required)
20
- - [Register Topic (create topic ACLs)](#register-topic-create-topic-acls)
21
- - [Create Topic](#create-topic)
22
- - [Start Producer](#start-producer)
23
- - [Start Consumer](#start-consumer)
24
- - [Delete Topic](#delete-topic)
25
- - [Unregister Topic (remove topic ACLs)](#unregister-topic-remove-topic-acls)
26
- - [Communicating with Kafka Using Your Preferred Client Library](#communicating-with-kafka-using-your-preferred-client-library)
27
- - [Register and Unregister Topic](#register-and-unregister-topic)
28
- - [Cluster Connection Details](#cluster-connection-details)
29
- - [Advanced Usage](#advanced-usage)
30
- - [Password Refresh](#password-refresh)
31
-
32
- ## Installation Instructions
33
- ### Recommended Installation with Kafka Client Library: kafka-python
34
- If you plan to utilize the `KafkaAdmin`, `KafkaProducer`, and `KafkaConsumer` classes in the SDK, which are extensions of the respective classes from the `kafka-python` library, we recommend installing the SDK with `kafka-python` support. This is especially convenient for tutorial purposes and integrating Kafka functionalities in your projects with out-of-box configurations.
19
+ * [Use the SDK to communicate with Kafka (kafka-python Required)](#use-the-sdk-to-communicate-with-kafka-kafka-python-required)
20
+ + [Register Topic (create topic ACLs)](#register-topic-create-topic-acls)
21
+ + [Start Producer](#start-producer)
22
+ + [Start Consumer](#start-consumer)
23
+ + [Unregister Topic (remove topic ACLs)](#unregister-topic-remove-topic-acls)
24
+ * [Use Your Preferred Kafka Client Library](#use-your-preferred-kafka-client-library)
25
+ + [Register and Unregister Topic](#register-and-unregister-topic)
26
+ + [Cluster Connection Details](#cluster-connection-details)
27
+ * [Advanced Usage](#advanced-usage)
28
+ + [Password Refresh](#password-refresh)
29
+ - [Common Issues](#common-issues)
30
+ * [ImportError: cannot import name 'KafkaProducer' from 'diaspora_event_sdk'](#importerror-cannot-import-name-kafkaproducer-from-diaspora_event_sdk)
31
+ * [kafka.errors.NoBrokersAvailable and kafka.errors.NodeNotReadyError](#kafkaerrorsnobrokersavailable-and-kafkaerrorsnodenotreadyerror)
32
+
33
+
34
+ ## Installation
35
+ ### Recommended Installation with Kafka Client Library
36
+ If you plan to utilize the `KafkaProducer` and `KafkaConsumer` classes in the SDK, which are extensions of the respective classes from the `kafka-python` library, we recommend installing the SDK with `kafka-python` support. This is especially convenient for tutorial purposes and integrating Kafka functionalities in your projects with out-of-box configurations.
35
37
 
36
38
  To install Diaspora Event SDK with `kafka-python`, run:
37
39
  ```bash
38
- pip install diaspora-event-sdk[kafka-python]
40
+ pip install "diaspora-event-sdk[kafka-python]"
39
41
  ```
40
42
 
41
43
  ### Installation Without Kafka Client Library
@@ -45,10 +47,10 @@ To install the SDK without Kafka support, simply run:
45
47
  ```bash
46
48
  pip install diaspora-event-sdk
47
49
  ```
48
- Note that this option does not install the necessary dependency for `KafkaAdmin`, `KafkaProducer`, and `KafkaConsumer` below to work.
50
+ Note that this option does not install the necessary dependency for `KafkaProducer` and `KafkaConsumer` below to work.
49
51
 
50
52
  ## Use Diaspora Event SDK
51
- ### Use SDK to communicate with Kafka (kafka-python Required)
53
+ ### Use the SDK to communicate with Kafka (kafka-python Required)
52
54
 
53
55
  #### Register Topic (create topic ACLs)
54
56
 
@@ -61,17 +63,7 @@ topic = "topic-" + c.subject_openid[-12:]
61
63
  print(c.register_topic(topic))
62
64
  print(c.list_topics())
63
65
  ```
64
-
65
- #### Create Topic
66
-
67
- Now use the KafkaAdmin to create the topic.
68
-
69
- ```python
70
- from diaspora_event_sdk import KafkaAdmin, NewTopic
71
- admin = KafkaAdmin()
72
- print(admin.create_topics(new_topics=[
73
- NewTopic(name=topic, num_partitions=1, replication_factor=1)]))
74
- ```
66
+ Register a topic also creates it, if the topic previously does not exist.
75
67
 
76
68
  #### Start Producer
77
69
 
@@ -96,13 +88,6 @@ for msg in consumer:
96
88
  print(msg)
97
89
  ```
98
90
 
99
- #### Delete Topic
100
- ```python
101
- from diaspora_event_sdk import KafkaAdmin
102
- admin = KafkaAdmin()
103
- print(admin.delete_topics(topics=[topic]))
104
- ```
105
-
106
91
  #### Unregister Topic (remove topic ACLs)
107
92
  ```python
108
93
  from diaspora_event_sdk import Client as GlobusClient
@@ -112,7 +97,7 @@ print(c.unregister_topic(topic))
112
97
  print(c.list_topics())
113
98
  ```
114
99
 
115
- ### Communicating with Kafka Using Your Preferred Client Library
100
+ ### Use Your Preferred Kafka Client Library
116
101
 
117
102
  #### Register and Unregister Topic
118
103
  The steps are the same as above by using the `register_topic`, `unregister_topic`, and `list_topics` methods from the `Client` class.
@@ -144,3 +129,12 @@ c = GlobusClient()
144
129
  print(c.create_key())
145
130
  ```
146
131
  Subsequent calls to `retrieve_key` will return the new password from the cache. This cache is reset with a logout or a new `create_key` call.
132
+
133
+ ## Common Issues
134
+
135
+ ### ImportError: cannot import name 'KafkaProducer' from 'diaspora_event_sdk'
136
+
137
+ It seems that you ran `pip install diaspora-event-sdk` to install the Diaspora Event SDK without `kafka-python`. Run `pip install kafka-python` to install the necessary dependency for our `KafkaProducer` and `KafkaConsumer` classes.
138
+
139
+ ### kafka.errors.NoBrokersAvailable and kafka.errors.NodeNotReadyError
140
+ These messages might pop up if `create_key` is called shortly before instanciating a Kafka client. This is because there's a delay for AWS Secret Manager to associate the newly generated credential with MSK. Note that `create_key` is called internally by `kafka_client.py` the first time you create one of these clients. Please wait a while (around 1 minute) and retry.
@@ -1,11 +1,11 @@
1
- diaspora_event_sdk/__init__.py,sha256=aog9b4ljY5AAdH5z7qEsjceBn5y--ENk8GIYULRpSeo,603
2
- diaspora_event_sdk/version.py,sha256=46Yjk3fz9o8aTN8E95McnzpJcjGzVJmHmQqUZ5mXzfc,22
1
+ diaspora_event_sdk/__init__.py,sha256=HecfCu-giI3bBGXcysQHmzkrX9wbwcXoU4k_uHeJWh0,540
2
+ diaspora_event_sdk/version.py,sha256=OaIl7v-6zEWEY90Jlh6yoBjO3zWX1oX7RsvqrK3o1TU,23
3
3
  diaspora_event_sdk/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  diaspora_event_sdk/sdk/_environments.py,sha256=UwzEeBVRuP7ZyqTJagNVA24EiCLuOYiy395q608AwQ0,358
5
- diaspora_event_sdk/sdk/client.py,sha256=PR9m8yJjK8RuDAwBKURV_0bupOcadHlD7cp5c7brmsk,3363
5
+ diaspora_event_sdk/sdk/client.py,sha256=DhUDtdkPRmn8P0fTXWg3x-Gn3p2J3ir0Ki7qeOFyp9I,3396
6
6
  diaspora_event_sdk/sdk/decorators.py,sha256=Gel8AyhIjbf4-FNintTNcOqvC9hHH_YwbOH257Nfmf0,884
7
- diaspora_event_sdk/sdk/kafka_client.py,sha256=BM_mIM3UxA8xhOhygCX02IruOdbW7kUd0iaqxOZCfd4,1721
8
- diaspora_event_sdk/sdk/web_client.py,sha256=rHYeEltujO191SksBXAMNrS6C_qasdf0xrFfBEcGhtQ,1349
7
+ diaspora_event_sdk/sdk/kafka_client.py,sha256=bfYKAAbgzRdeMK_gmr84n5653KYboWjO6F4BjgmWExs,1524
8
+ diaspora_event_sdk/sdk/web_client.py,sha256=BgRza0fJudvgRCZ_P9BugFp57oYRWekpBf2KlZYFqUY,1305
9
9
  diaspora_event_sdk/sdk/login_manager/__init__.py,sha256=yeqVgjeHLMX0WZJu2feJmq-fbeXvSxWghVV81ygfY-w,239
10
10
  diaspora_event_sdk/sdk/login_manager/client_login.py,sha256=gvR4PkIqQpIywNieJQ_u11PHUmdLxQ0Ho-QgPSfu8bw,1798
11
11
  diaspora_event_sdk/sdk/login_manager/decorators.py,sha256=EFEp71d0oJ7vo2H8W7DJ2gPrDfGzeNXUNxri1C0l8h0,1047
@@ -16,8 +16,8 @@ diaspora_event_sdk/sdk/login_manager/protocol.py,sha256=RCuo2jy_XkpZvbxnKlDfTKs-
16
16
  diaspora_event_sdk/sdk/login_manager/tokenstore.py,sha256=7jRm01rzsbvniaCfYtDDWE3det_1_b6oQkS-YQ2Qjg4,3037
17
17
  diaspora_event_sdk/sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  diaspora_event_sdk/sdk/utils/uuid_like.py,sha256=xbxf0YXpDhdii16lwPLWRN21qFekHrNrqODSToMPtCg,470
19
- diaspora_event_sdk-0.0.9.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
20
- diaspora_event_sdk-0.0.9.dist-info/METADATA,sha256=8CUAyZbTsolEBN4LqnWAUJNx7hqvKMEtblRNv6FbKbE,6488
21
- diaspora_event_sdk-0.0.9.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
22
- diaspora_event_sdk-0.0.9.dist-info/top_level.txt,sha256=_5Wx8F5rc9mpB093wvCXa6CArtWNXwek2T1LnmkS2vE,19
23
- diaspora_event_sdk-0.0.9.dist-info/RECORD,,
19
+ diaspora_event_sdk-0.0.11.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
20
+ diaspora_event_sdk-0.0.11.dist-info/METADATA,sha256=jPFx9QiJ0uYkRqzWYIxeAiHa_sSRWmAguT-ANlJIp4Y,7049
21
+ diaspora_event_sdk-0.0.11.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
22
+ diaspora_event_sdk-0.0.11.dist-info/top_level.txt,sha256=_5Wx8F5rc9mpB093wvCXa6CArtWNXwek2T1LnmkS2vE,19
23
+ diaspora_event_sdk-0.0.11.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5