diaspora-event-sdk 0.1.1__py3-none-any.whl → 0.1.2__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,7 +10,7 @@ kafka_available = True
10
10
  try:
11
11
  from kafka import KafkaProducer as KProd # type: ignore[import,import-not-found]
12
12
  from kafka import KafkaConsumer as KCons # type: ignore[import,import-not-found]
13
- from aws_msk_iam_sasl_signer import MSKAuthTokenProvider
13
+ from aws_msk_iam_sasl_signer import MSKAuthTokenProvider # type: ignore[import,import-not-found]
14
14
  import os
15
15
 
16
16
  class MSKTokenProvider:
@@ -56,6 +56,7 @@ if kafka_available:
56
56
  class KafkaConsumer(KCons):
57
57
  def __init__(self, *topics, **configs):
58
58
  super().__init__(*topics, **get_diaspora_config(configs))
59
+
59
60
  else:
60
61
  # Create dummy classes that issue a warning when instantiated
61
62
  class KafkaProducer: # type: ignore[no-redef]
@@ -22,7 +22,7 @@ log = logging.getLogger(__name__)
22
22
  def _get_diaspora_all_scope() -> str:
23
23
  return os.getenv(
24
24
  "DIASPORA_SCOPE",
25
- f"https://auth.globus.org/scopes/{DIASPORA_RESOURCE_SERVER}/action_all"
25
+ f"https://auth.globus.org/scopes/{DIASPORA_RESOURCE_SERVER}/action_all",
26
26
  )
27
27
 
28
28
 
@@ -57,8 +57,7 @@ class LoginManager:
57
57
  }
58
58
 
59
59
  def __init__(self, *, environment: str | None = None) -> None:
60
- self._token_storage = get_token_storage_adapter(
61
- environment=environment)
60
+ self._token_storage = get_token_storage_adapter(environment=environment)
62
61
  self._access_lock = threading.Lock()
63
62
 
64
63
  @property
@@ -7,7 +7,6 @@ from ._environments import TOKEN_EXCHANGE
7
7
 
8
8
 
9
9
  class WebClient(globus_sdk.BaseClient):
10
-
11
10
  def __init__(
12
11
  self,
13
12
  *,
@@ -25,13 +24,21 @@ class WebClient(globus_sdk.BaseClient):
25
24
  self.user_app_name = app_name
26
25
 
27
26
  def create_key(self, subject: UUID_LIKE_T) -> globus_sdk.GlobusHTTPResponse:
28
- return self.post("/v2/create_key", headers={"Subject": str(subject)})
27
+ return self.post("/v1/create_key", headers={"Subject": str(subject)})
29
28
 
30
29
  def list_topics(self, subject: UUID_LIKE_T) -> globus_sdk.GlobusHTTPResponse:
31
- return self.get("/v2/list_topics", headers={"Subject": str(subject)})
32
-
33
- def register_topic(self, subject: UUID_LIKE_T, topic: str) -> globus_sdk.GlobusHTTPResponse:
34
- return self.post("/v2/register_topic", headers={"Subject": str(subject), "Topic": topic})
35
-
36
- def unregister_topic(self, subject: UUID_LIKE_T, topic: str) -> globus_sdk.GlobusHTTPResponse:
37
- return self.post("/v2/unregister_topic", headers={"Subject": str(subject), "Topic": topic})
30
+ return self.get("/v1/list_topics", headers={"Subject": str(subject)})
31
+
32
+ def register_topic(
33
+ self, subject: UUID_LIKE_T, topic: str
34
+ ) -> globus_sdk.GlobusHTTPResponse:
35
+ return self.post(
36
+ "/v1/register_topic", headers={"Subject": str(subject), "Topic": topic}
37
+ )
38
+
39
+ def unregister_topic(
40
+ self, subject: UUID_LIKE_T, topic: str
41
+ ) -> globus_sdk.GlobusHTTPResponse:
42
+ return self.post(
43
+ "/v1/unregister_topic", headers={"Subject": str(subject), "Topic": topic}
44
+ )
@@ -1 +1 @@
1
- __version__ = "0.1.1"
1
+ __version__ = "0.1.2"
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.1
2
+ Name: diaspora-event-sdk
3
+ Version: 0.1.2
4
+ Summary: SDK of Diaspora Event Fabric: Resilience-enabling services for science from HPC to edge
5
+ Home-page: https://github.com/globus-labs/diaspora-event-sdk
6
+ License: LICENSE
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: globus-sdk <4,>=3.20.1
10
+ Provides-Extra: kafka-python
11
+ Requires-Dist: kafka-python ; extra == 'kafka-python'
12
+ Requires-Dist: aws-msk-iam-sasl-signer-python ; extra == 'kafka-python'
13
+ Provides-Extra: test
14
+ Requires-Dist: pytest ; extra == 'test'
15
+ Requires-Dist: pytest-cov ; extra == 'test'
16
+ Requires-Dist: coverage ; extra == 'test'
17
+ Requires-Dist: mypy ; extra == 'test'
18
+ Requires-Dist: tox ; extra == 'test'
19
+ Requires-Dist: check-manifest ; extra == 'test'
20
+
21
+ # Diaspora: Resilience-enabling services for science from HPC to edge
22
+
23
+ ## Event Fabric SDK Installation Guide
24
+ ### Recommended Method: Use with `kafka-python`
25
+ For easy integration with Diaspora Event Fabric, use the `KafkaProducer` and `KafkaConsumer` classes from our SDK. This requires the `kafka-python` library.
26
+
27
+ To install the Event Fabric SDK and `kafka-python,` with the following command:
28
+ ```bash
29
+ pip install "diaspora-event-sdk[kafka-python]"
30
+ ```
31
+
32
+ ### Alternative Installation: Without Kafka Client Library
33
+ To use alternative Kafka client libraries (e.g., `confluent-kafka-python`, `aiokafka`, and libraries for other programming laguages), you can install the SDK without the `kafka-python` dependency. This option still provides topic-level access control (authorization) and login credential management features.
34
+
35
+ To install the SDK without `kafka-python`, use:
36
+ ```bash
37
+ pip install diaspora-event-sdk
38
+ ```
39
+ Note: This method does not include dependencies for `KafkaProducer` and `KafkaConsumer` classes mentioned in the QuickStart
40
+
41
+ ## Use Diaspora Event Fabric SDK
42
+
43
+ **Getting Started**: Visit our [QuickStart Guide](docs/quickstart.md) for details on using the SDK with the kafka-python library and instructions for other Kafka clients.
44
+
45
+ **Troubleshooting and Credential Management**: Consult our [TrobleShooting Guide](docs/troubleshooting.md) for solving common issues and tips on managing keys effectively.
46
+
47
+ **Advanced Usage**: Explore the [Faust Streaming Guide](docs/faust_weather_app.md) for advanced event streaming with Faust.
@@ -1,25 +1,25 @@
1
1
  diaspora_event_sdk/__init__.py,sha256=v8IN3-WFpliakQKru8TAcmQ4IRdvRe_m9-abSDnGIFM,457
2
- diaspora_event_sdk/version.py,sha256=rnObPjuBcEStqSO0S6gsdS_ot8ITOQjVj_-P1LUUYpg,22
2
+ diaspora_event_sdk/version.py,sha256=YvuYzWnKtqBb-IqG8HAu-nhIYAsgj9Vmc_b9o7vO-js,22
3
3
  diaspora_event_sdk/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  diaspora_event_sdk/sdk/_environments.py,sha256=Xeuzqnx1aGou01vsXgGwQkWhgIe3-PRgbOr1o5mZ3Mk,203
5
5
  diaspora_event_sdk/sdk/client.py,sha256=ucv2C-bWzwTTORNJuWpVpki6pNvUYPA1IXKX2GAmh2M,4999
6
6
  diaspora_event_sdk/sdk/decorators.py,sha256=Gel8AyhIjbf4-FNintTNcOqvC9hHH_YwbOH257Nfmf0,884
7
- diaspora_event_sdk/sdk/kafka_client.py,sha256=k0tDxHKFm6r7TODCfb3XyJSa6jNPHPo1kVPF2luMyLc,4319
8
- diaspora_event_sdk/sdk/web_client.py,sha256=hPeqlq2XFL1sYZtN2qsi7d-dCRJ7jjSUBBguzGcrEyc,1325
7
+ diaspora_event_sdk/sdk/kafka_client.py,sha256=G1kQQz2TWlahdd2TDdpvaQW7HD7gsuQCnr0tks54ISw,4361
8
+ diaspora_event_sdk/sdk/web_client.py,sha256=ryvirr0sz0sF5YvQl50mWpw-1tnK-d5f8eAKvClEYSk,1396
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
12
12
  diaspora_event_sdk/sdk/login_manager/globus_auth.py,sha256=9Hymp0tv91OI5dBMUgh4rGv_5xLVLhFEK7Hu0t8CJFQ,389
13
13
  diaspora_event_sdk/sdk/login_manager/login_flow.py,sha256=2TodgsvlEYPoZPQPkp6FHOC9IkSM07pS7MIVGS4MZNE,954
14
- diaspora_event_sdk/sdk/login_manager/manager.py,sha256=uJHosI7ipqGt5KiL-iv2IGB4bNyZ6jQZQi7g4ka0pts,7052
14
+ diaspora_event_sdk/sdk/login_manager/manager.py,sha256=AD3f8rx154oesgkpqG0K-eZsEGjntr08Vgrxr1m6uao,7040
15
15
  diaspora_event_sdk/sdk/login_manager/protocol.py,sha256=RCuo2jy_XkpZvbxnKlDfTKs-L6b9_8_JR-Kq9wHwhoM,710
16
16
  diaspora_event_sdk/sdk/login_manager/tokenstore.py,sha256=Kq0IZGf9G9dE44yoyUZInod5xL_8caN9OugeTK6GBGg,2094
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
19
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- tests/unit/test_client.py,sha256=KjqXW7Mm3fm17lqhYdixL8s50z83F6g7MGKcOXJIyFc,2635
21
- diaspora_event_sdk-0.1.1.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
22
- diaspora_event_sdk-0.1.1.dist-info/METADATA,sha256=JOKh9Pc_eGy96RXmwELcttejLJ1m2zWBHVQkeu_QK-8,2180
23
- diaspora_event_sdk-0.1.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
24
- diaspora_event_sdk-0.1.1.dist-info/top_level.txt,sha256=OVun-67t3fkLFEIwvJuNINgFFvAc--bClYhXjLhMmvs,25
25
- diaspora_event_sdk-0.1.1.dist-info/RECORD,,
20
+ tests/unit/test_client.py,sha256=alUC-XTRQn_Oz0RvmzXTal-ciSVtCpx5jm3NuStkt1E,2995
21
+ diaspora_event_sdk-0.1.2.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
22
+ diaspora_event_sdk-0.1.2.dist-info/METADATA,sha256=TZwWZMDSreUPJGvBeh3_wt8Z5TO5_xmfvjredJPL-DM,2307
23
+ diaspora_event_sdk-0.1.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
24
+ diaspora_event_sdk-0.1.2.dist-info/top_level.txt,sha256=OVun-67t3fkLFEIwvJuNINgFFvAc--bClYhXjLhMmvs,25
25
+ diaspora_event_sdk-0.1.2.dist-info/RECORD,,
tests/unit/test_client.py CHANGED
@@ -1,20 +1,31 @@
1
1
  import pytest
2
- from unittest.mock import Mock, patch
2
+ from unittest.mock import Mock
3
3
  from unittest.mock import MagicMock
4
4
  from diaspora_event_sdk import Client
5
5
  from diaspora_event_sdk.sdk.web_client import WebClient
6
6
  from diaspora_event_sdk.sdk.login_manager import LoginManager
7
7
 
8
+
8
9
  @pytest.fixture
9
- def mock_login_manager(): # TODO
10
+ def mock_login_manager(): # TODO
10
11
  login_manager = Mock(spec=LoginManager())
11
12
  login_manager.get_web_client.return_value = Mock(spec=WebClient)
12
13
  login_manager.get_auth_client.return_value = Mock(
13
- oauth2_userinfo=lambda: {"sub": "test_sub"})
14
+ oauth2_userinfo=lambda: {"sub": "test_sub"}
15
+ )
14
16
  login_manager._token_storage.get_token_data.return_value = {
15
- 'access_key': 'test_access', 'secret_key': 'test_secret'}
17
+ "username": "test_sub",
18
+ "access_key": "test_access",
19
+ "secret_key": "test_secret",
20
+ "endpoint": "test_endpoint",
21
+ }
16
22
  login_manager.get_web_client.return_value.create_key.return_value = {
17
- "status": "success", "access_key": "new_access", "secret_key": "new_secret"}
23
+ "status": "success",
24
+ "username": "test_sub",
25
+ "access_key": "new_access",
26
+ "secret_key": "new_secret",
27
+ "endpoint": "new_endpoint",
28
+ }
18
29
 
19
30
  # Use MagicMock for _access_lock
20
31
  login_manager._access_lock = MagicMock()
@@ -40,12 +51,20 @@ def test_logout(client):
40
51
 
41
52
  def test_create_key(client):
42
53
  result = client.create_key()
43
- assert result == {"username": "test_sub", "password": "new_secret"}
54
+ assert result == {
55
+ "access_key": "new_access",
56
+ "secret_key": "new_secret",
57
+ "endpoint": "new_endpoint",
58
+ }
44
59
 
45
60
 
46
61
  def test_retrieve_key_existing(client):
47
62
  result = client.retrieve_key()
48
- assert result == {"username": "test_sub", "password": "test_secret"}
63
+ assert result == {
64
+ "access_key": "test_access",
65
+ "secret_key": "test_secret",
66
+ "endpoint": "test_endpoint",
67
+ }
49
68
 
50
69
 
51
70
  def test_retrieve_key_missing(client, mock_login_manager):
@@ -53,14 +72,15 @@ def test_retrieve_key_missing(client, mock_login_manager):
53
72
  # the second call returns scope, resource_server, access_token, refresh_token, etc.
54
73
  mock_login_manager._token_storage.get_token_data.side_effect = [
55
74
  None,
56
- {'scope': 'scope', 'resource_server': 'resource_server'}
75
+ {"scope": "scope", "resource_server": "resource_server"},
57
76
  ]
58
77
 
59
78
  # should internally call create_key
60
79
  result = client.retrieve_key()
61
80
 
62
- assert result["username"] == "test_sub"
63
- assert result["password"] == "new_secret"
81
+ assert result["access_key"] == "new_access"
82
+ assert result["secret_key"] == "new_secret"
83
+ assert result["endpoint"] == "new_endpoint"
64
84
 
65
85
 
66
86
  def test_list_topics(client):
@@ -1,47 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: diaspora-event-sdk
3
- Version: 0.1.1
4
- Summary: SDK of Diaspora Event Fabric: Resilience-enabling services for science from HPC to edge
5
- Home-page: https://github.com/globus-labs/diaspora-event-sdk
6
- License: LICENSE
7
- Description-Content-Type: text/markdown
8
- License-File: LICENSE
9
- Requires-Dist: globus-sdk <4,>=3.20.1
10
- Provides-Extra: kafka-python
11
- Requires-Dist: kafka-python ; extra == 'kafka-python'
12
- Requires-Dist: aws-msk-iam-sasl-signer-python ; extra == 'kafka-python'
13
- Provides-Extra: test
14
- Requires-Dist: pytest ; extra == 'test'
15
- Requires-Dist: pytest-cov ; extra == 'test'
16
- Requires-Dist: coverage ; extra == 'test'
17
- Requires-Dist: mypy ; extra == 'test'
18
- Requires-Dist: tox ; extra == 'test'
19
- Requires-Dist: check-manifest ; extra == 'test'
20
-
21
- <h1>Diaspora Event Fabric: Resilience-enabling services for science from HPC to edge</h1>
22
-
23
- ## Installation
24
- ### Recommended Installation with Kafka Client Library
25
- The `KafkaProducer` and `KafkaConsumer` classes within the SDK are designed for seamless integration with Diaspora Event Fabric using pre-configured settings. For utilizing these classes, the `kafka-python` library is necessary.
26
-
27
- To install the Diaspora Event SDK along with `kafka-python,` execute:
28
- ```bash
29
- pip install "diaspora-event-sdk[kafka-python]"
30
- ```
31
-
32
- ### Installation Without Kafka Client Library
33
- If you prefer using different client libraries for Kafka communication, you can install the SDK without the kafka-python dependency. The SDK still serves for topic-level access control (authorization) and login credential management (authentication).
34
-
35
- To install the SDK without client libraries, simply run:
36
- ```bash
37
- pip install diaspora-event-sdk
38
- ```
39
- Note: This does not install the necessary dependency for `KafkaProducer` and `KafkaConsumer` classes.
40
-
41
- ## Use Diaspora Event Fabric SDK
42
-
43
- Please refer to our [QuickStart Guide](docs/quickstart.md) for recommended use with `kafka-python` library as well as steps to use your own Kafka client.
44
-
45
- Please refer to our [TrobleShooting Guide](docs/troubleshooting.md) for debugging common problems and effective key management strategies.
46
-
47
- [Topic: Use faust to Process Records](docs/faust_weather_app.md)