kbm-ledsas-sdk 0.3.2__tar.gz
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.
- kbm_ledsas_sdk-0.3.2/LICENSE +201 -0
- kbm_ledsas_sdk-0.3.2/NOTICE +9 -0
- kbm_ledsas_sdk-0.3.2/PKG-INFO +203 -0
- kbm_ledsas_sdk-0.3.2/README.md +164 -0
- kbm_ledsas_sdk-0.3.2/pyproject.toml +109 -0
- kbm_ledsas_sdk-0.3.2/setup.cfg +4 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/__init__.py +77 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/amqp/__init__.py +0 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/amqp/consumer.py +457 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/amqp/publisher.py +316 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/amqp/topology.py +262 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/app.py +772 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/blob/__init__.py +10 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/blob/azure_client.py +661 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/blob/direct_operations.py +417 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/blob/operations.py +277 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/health/__init__.py +39 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/health/checks.py +68 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/health/server.py +268 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/models/__init__.py +34 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/models/blob.py +177 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/models/envelope.py +195 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/models/errors.py +105 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/models/messages.py +145 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/py.typed +0 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/runtime/__init__.py +19 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/runtime/config.py +345 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/runtime/context.py +189 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/runtime/env_vars.py +249 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/runtime/handler.py +443 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/runtime/security.py +147 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/transport/__init__.py +19 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/transport/base.py +191 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/transport/direct.py +512 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/transport/factory.py +49 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/transport/mock.py +261 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/utils/__init__.py +45 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/utils/logging.py +263 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk/utils/tracing.py +214 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk.egg-info/PKG-INFO +203 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk.egg-info/SOURCES.txt +42 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk.egg-info/dependency_links.txt +1 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk.egg-info/requires.txt +13 -0
- kbm_ledsas_sdk-0.3.2/src/kbm_ledsas_sdk.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025-2026 KeborMed
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
KeborMed LEDSAS SDK
|
|
2
|
+
Copyright 2025-2026 KeborMed
|
|
3
|
+
|
|
4
|
+
This product includes software developed at KeborMed (https://kebormed.com).
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (see the LICENSE file).
|
|
7
|
+
|
|
8
|
+
This product depends on third-party open-source software. See
|
|
9
|
+
THIRD_PARTY_NOTICES.txt for the full list of dependencies and their licenses.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kbm-ledsas-sdk
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: KeborMed LEDSAS SDK - Python client for building Local External Data Sources Action Service (LEDSAS) data-processing services
|
|
5
|
+
Author-email: KeborMed <support@kebormed.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Kubyk-Health/kbm-ledsas-sdk
|
|
8
|
+
Project-URL: Repository, https://github.com/Kubyk-Health/kbm-ledsas-sdk
|
|
9
|
+
Project-URL: Issues, https://github.com/Kubyk-Health/kbm-ledsas-sdk/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: ledsas,kebormed,rabbitmq,azure-blob,medical,data-processing,sdk
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
License-File: NOTICE
|
|
26
|
+
Requires-Dist: pydantic<3.0,>=2.5.0
|
|
27
|
+
Requires-Dist: aio-pika<10.0,>=9.4.0
|
|
28
|
+
Requires-Dist: azure-storage-blob<13.0,>=12.19.0
|
|
29
|
+
Requires-Dist: aiohttp<4.0,>=3.8.0
|
|
30
|
+
Requires-Dist: cryptography>=48.0.1
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff<0.15,>=0.5; extra == "dev"
|
|
35
|
+
Requires-Dist: black<26,>=24.0; extra == "dev"
|
|
36
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
37
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# KeborMed LEDSAS SDK (Python)
|
|
41
|
+
|
|
42
|
+
[](https://github.com/Kubyk-Health/kbm-ledsas-sdk/actions/workflows/ci.yml)
|
|
43
|
+
[](https://pypi.org/project/kbm-ledsas-sdk/)
|
|
44
|
+
[](https://pypi.org/project/kbm-ledsas-sdk/)
|
|
45
|
+
[](LICENSE)
|
|
46
|
+
|
|
47
|
+
A Python client SDK for building **LEDSAS** (Local External Data Sources Action Service)
|
|
48
|
+
data-processing services. You write async handler functions; the SDK consumes command
|
|
49
|
+
messages from **RabbitMQ**, runs your handler, reads and writes payloads in **Azure Blob
|
|
50
|
+
Storage**, and (optionally) publishes the response back to the caller.
|
|
51
|
+
|
|
52
|
+
It handles the plumbing — message consumption, acknowledgement, retries, timeouts,
|
|
53
|
+
structured logging, health/readiness endpoints, and blob I/O — so your service code stays
|
|
54
|
+
focused on the data transformation.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
- **Handler-based programming model** — register `async` handlers with a decorator.
|
|
61
|
+
- **RabbitMQ consumption** with prefetch, bounded concurrency, ack/nack semantics, and a
|
|
62
|
+
dead-letter path for poison messages.
|
|
63
|
+
- **Azure Blob Storage** helpers: `download_bytes/text/json/stream`, `upload_bytes/text/json`,
|
|
64
|
+
and memory-bounded streaming for large files.
|
|
65
|
+
- **Typed models** (Pydantic v2) for blob references and message envelopes.
|
|
66
|
+
- **Built-in retries & timeouts** with permanent vs. transient error classes.
|
|
67
|
+
- **Health & readiness** HTTP endpoints (`/health`, `/ready`, `/livez`, `/readyz`) with
|
|
68
|
+
pluggable liveness/readiness checks.
|
|
69
|
+
- **Structured JSON logging** out of the box.
|
|
70
|
+
- **Fully type-hinted** (`py.typed`), Python 3.11+.
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install kbm-ledsas-sdk
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
To work from a clone — or before a release is published to PyPI — install from source:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
git clone https://github.com/Kubyk-Health/kbm-ledsas-sdk.git
|
|
82
|
+
cd kbm-ledsas-sdk
|
|
83
|
+
pip install -e . # add "[dev]" for the test/lint toolchain: pip install -e ".[dev]"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Quickstart
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import logging
|
|
90
|
+
from kbm_ledsas_sdk import ServiceApp, errors
|
|
91
|
+
|
|
92
|
+
logging.basicConfig(level=logging.INFO)
|
|
93
|
+
|
|
94
|
+
app = ServiceApp(service_name="csv-processor")
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@app.handler("ProcessCSV")
|
|
98
|
+
async def handle(ctx, req: dict) -> dict:
|
|
99
|
+
csv_uri = req.get("csv_uri")
|
|
100
|
+
if not csv_uri:
|
|
101
|
+
# user_message is what the caller sees; the internal message goes to logs.
|
|
102
|
+
raise errors.Permanent(
|
|
103
|
+
"Validation: csv_uri missing",
|
|
104
|
+
user_message="csv_uri is required",
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
text = await ctx.blob.download_text(csv_uri)
|
|
108
|
+
container = csv_uri.replace("azblob://", "").split("/", 1)[0]
|
|
109
|
+
|
|
110
|
+
out = await ctx.blob.upload_json(
|
|
111
|
+
container=container,
|
|
112
|
+
obj={"rows": len(text.splitlines()) - 1},
|
|
113
|
+
# Use idempotency_key (not message_id) so a redelivery of the same logical
|
|
114
|
+
# request overwrites the same blob. overwrite=True is required for that.
|
|
115
|
+
path=f"result-{ctx.idempotency_key}.json",
|
|
116
|
+
overwrite=True,
|
|
117
|
+
)
|
|
118
|
+
return {"result_uri": out.uri}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
# Optional readiness hook (the SDK ships sensible defaults; this layers on top).
|
|
122
|
+
@app.readiness_check("warmup_done")
|
|
123
|
+
def _() -> bool:
|
|
124
|
+
return True
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
if __name__ == "__main__":
|
|
128
|
+
app.run()
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Run it against a local RabbitMQ + Azure Blob (Azurite):
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
export KBM_LEDSAS_RABBITMQ_URL="amqp://guest:guest@127.0.0.1:5672/"
|
|
135
|
+
export KBM_LEDSAS_BLOB_CONN_STRING="DefaultEndpointsProtocol=http;AccountName=...;AccountKey=...;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;"
|
|
136
|
+
python my_service.py
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The service also exposes health endpoints at
|
|
140
|
+
`http://127.0.0.1:8090/health` and `/ready` (loopback only by default; set
|
|
141
|
+
`KBM_LEDSAS_HEALTH_HOST=0.0.0.0` to bind all interfaces).
|
|
142
|
+
|
|
143
|
+
## Local development
|
|
144
|
+
|
|
145
|
+
A ready-to-run stack (RabbitMQ + Azurite) is provided with the example service:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
cd examples/hello_world_service
|
|
149
|
+
pip install -e ../.. # install the SDK from this repo
|
|
150
|
+
docker compose -f deploy/local/docker-compose.yml up -d # start RabbitMQ + Azurite
|
|
151
|
+
python main.py # run the example service
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
See [`examples/hello_world_service/`](https://github.com/Kubyk-Health/kbm-ledsas-sdk/tree/main/examples/hello_world_service) for a complete,
|
|
155
|
+
runnable service (handler, sender script, tests, `Dockerfile`, and a local
|
|
156
|
+
`docker compose` stack under `deploy/local/`).
|
|
157
|
+
|
|
158
|
+
## Configuration
|
|
159
|
+
|
|
160
|
+
The SDK is configured through environment variables. The most common are below; see the [API reference](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/docs/SDK_API_REFERENCE.md#environment-variables) for the complete list (including `KBM_LEDSAS_ALLOW_INSECURE_AMQP`, `KBM_LEDSAS_MAX_PAYLOAD_BYTES`, and other advanced settings):
|
|
161
|
+
|
|
162
|
+
| Variable | Description | Default |
|
|
163
|
+
|----------|-------------|---------|
|
|
164
|
+
| `KBM_LEDSAS_SERVICE_NAME` | Service name used for message routing | *(required)* |
|
|
165
|
+
| `KBM_LEDSAS_TENANT` | Tenant identifier | *(optional)* |
|
|
166
|
+
| `KBM_LEDSAS_RABBITMQ_URL` | RabbitMQ connection URL | *(required)* |
|
|
167
|
+
| `KBM_LEDSAS_BLOB_CONN_STRING` | Azure Blob Storage connection string | *(required)* |
|
|
168
|
+
| `KBM_LEDSAS_CONTAINER` | Default blob container | `dev` |
|
|
169
|
+
| `KBM_LEDSAS_PREFETCH` | AMQP prefetch count | `10` |
|
|
170
|
+
| `KBM_LEDSAS_CONCURRENCY` | Worker concurrency | `4` |
|
|
171
|
+
| `KBM_LEDSAS_HANDLER_TIMEOUT` | Per-handler timeout (seconds) | `1800` |
|
|
172
|
+
| `KBM_LEDSAS_MAX_RETRIES` | Max retries for transient failures | `3` |
|
|
173
|
+
| `KBM_LEDSAS_LOG_LEVEL` | Log level | `INFO` |
|
|
174
|
+
| `KBM_LEDSAS_LOG_FORMAT` | Log format (`json` or `text`) | `json` |
|
|
175
|
+
| `KBM_LEDSAS_HEALTH_HOST` | Health server bind host | `127.0.0.1` |
|
|
176
|
+
| `KBM_LEDSAS_HEALTH_PORT` | Health server port | `8090` |
|
|
177
|
+
| `KBM_LEDSAS_DEPLOYMENT_ID` | Build/commit id surfaced as `deployment_id` in `/health` and `/ready` | *(optional)* |
|
|
178
|
+
|
|
179
|
+
## Documentation
|
|
180
|
+
|
|
181
|
+
- [API Reference](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/docs/SDK_API_REFERENCE.md)
|
|
182
|
+
- [Example service](https://github.com/Kubyk-Health/kbm-ledsas-sdk/tree/main/examples/hello_world_service)
|
|
183
|
+
- [Changelog](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/CHANGELOG.md)
|
|
184
|
+
|
|
185
|
+
## Contributing
|
|
186
|
+
|
|
187
|
+
Contributions are welcome! Please read [CONTRIBUTING.md](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/CONTRIBUTING.md) first — it covers
|
|
188
|
+
the development setup, how to run the tests, the coding style, and the **Developer Certificate
|
|
189
|
+
of Origin (DCO)** sign-off we require on every commit. Also see our
|
|
190
|
+
[Code of Conduct](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/CODE_OF_CONDUCT.md).
|
|
191
|
+
|
|
192
|
+
## Security
|
|
193
|
+
|
|
194
|
+
Please report vulnerabilities privately — see [SECURITY.md](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/SECURITY.md). Do **not** open a
|
|
195
|
+
public issue for security reports.
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
Licensed under the [Apache License 2.0](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/LICENSE). Copyright © 2025-2026 KeborMed.
|
|
200
|
+
See [THIRD_PARTY_NOTICES.txt](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/THIRD_PARTY_NOTICES.txt) for third-party dependency licenses.
|
|
201
|
+
|
|
202
|
+
Maintained by **KeborMed** (the software's copyright holder) under the
|
|
203
|
+
[**Kubyk-Health**](https://github.com/Kubyk-Health) GitHub organization.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# KeborMed LEDSAS SDK (Python)
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Kubyk-Health/kbm-ledsas-sdk/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/kbm-ledsas-sdk/)
|
|
5
|
+
[](https://pypi.org/project/kbm-ledsas-sdk/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
A Python client SDK for building **LEDSAS** (Local External Data Sources Action Service)
|
|
9
|
+
data-processing services. You write async handler functions; the SDK consumes command
|
|
10
|
+
messages from **RabbitMQ**, runs your handler, reads and writes payloads in **Azure Blob
|
|
11
|
+
Storage**, and (optionally) publishes the response back to the caller.
|
|
12
|
+
|
|
13
|
+
It handles the plumbing — message consumption, acknowledgement, retries, timeouts,
|
|
14
|
+
structured logging, health/readiness endpoints, and blob I/O — so your service code stays
|
|
15
|
+
focused on the data transformation.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- **Handler-based programming model** — register `async` handlers with a decorator.
|
|
22
|
+
- **RabbitMQ consumption** with prefetch, bounded concurrency, ack/nack semantics, and a
|
|
23
|
+
dead-letter path for poison messages.
|
|
24
|
+
- **Azure Blob Storage** helpers: `download_bytes/text/json/stream`, `upload_bytes/text/json`,
|
|
25
|
+
and memory-bounded streaming for large files.
|
|
26
|
+
- **Typed models** (Pydantic v2) for blob references and message envelopes.
|
|
27
|
+
- **Built-in retries & timeouts** with permanent vs. transient error classes.
|
|
28
|
+
- **Health & readiness** HTTP endpoints (`/health`, `/ready`, `/livez`, `/readyz`) with
|
|
29
|
+
pluggable liveness/readiness checks.
|
|
30
|
+
- **Structured JSON logging** out of the box.
|
|
31
|
+
- **Fully type-hinted** (`py.typed`), Python 3.11+.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install kbm-ledsas-sdk
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
To work from a clone — or before a release is published to PyPI — install from source:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/Kubyk-Health/kbm-ledsas-sdk.git
|
|
43
|
+
cd kbm-ledsas-sdk
|
|
44
|
+
pip install -e . # add "[dev]" for the test/lint toolchain: pip install -e ".[dev]"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Quickstart
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import logging
|
|
51
|
+
from kbm_ledsas_sdk import ServiceApp, errors
|
|
52
|
+
|
|
53
|
+
logging.basicConfig(level=logging.INFO)
|
|
54
|
+
|
|
55
|
+
app = ServiceApp(service_name="csv-processor")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@app.handler("ProcessCSV")
|
|
59
|
+
async def handle(ctx, req: dict) -> dict:
|
|
60
|
+
csv_uri = req.get("csv_uri")
|
|
61
|
+
if not csv_uri:
|
|
62
|
+
# user_message is what the caller sees; the internal message goes to logs.
|
|
63
|
+
raise errors.Permanent(
|
|
64
|
+
"Validation: csv_uri missing",
|
|
65
|
+
user_message="csv_uri is required",
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
text = await ctx.blob.download_text(csv_uri)
|
|
69
|
+
container = csv_uri.replace("azblob://", "").split("/", 1)[0]
|
|
70
|
+
|
|
71
|
+
out = await ctx.blob.upload_json(
|
|
72
|
+
container=container,
|
|
73
|
+
obj={"rows": len(text.splitlines()) - 1},
|
|
74
|
+
# Use idempotency_key (not message_id) so a redelivery of the same logical
|
|
75
|
+
# request overwrites the same blob. overwrite=True is required for that.
|
|
76
|
+
path=f"result-{ctx.idempotency_key}.json",
|
|
77
|
+
overwrite=True,
|
|
78
|
+
)
|
|
79
|
+
return {"result_uri": out.uri}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# Optional readiness hook (the SDK ships sensible defaults; this layers on top).
|
|
83
|
+
@app.readiness_check("warmup_done")
|
|
84
|
+
def _() -> bool:
|
|
85
|
+
return True
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
if __name__ == "__main__":
|
|
89
|
+
app.run()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Run it against a local RabbitMQ + Azure Blob (Azurite):
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
export KBM_LEDSAS_RABBITMQ_URL="amqp://guest:guest@127.0.0.1:5672/"
|
|
96
|
+
export KBM_LEDSAS_BLOB_CONN_STRING="DefaultEndpointsProtocol=http;AccountName=...;AccountKey=...;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;"
|
|
97
|
+
python my_service.py
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The service also exposes health endpoints at
|
|
101
|
+
`http://127.0.0.1:8090/health` and `/ready` (loopback only by default; set
|
|
102
|
+
`KBM_LEDSAS_HEALTH_HOST=0.0.0.0` to bind all interfaces).
|
|
103
|
+
|
|
104
|
+
## Local development
|
|
105
|
+
|
|
106
|
+
A ready-to-run stack (RabbitMQ + Azurite) is provided with the example service:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cd examples/hello_world_service
|
|
110
|
+
pip install -e ../.. # install the SDK from this repo
|
|
111
|
+
docker compose -f deploy/local/docker-compose.yml up -d # start RabbitMQ + Azurite
|
|
112
|
+
python main.py # run the example service
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
See [`examples/hello_world_service/`](https://github.com/Kubyk-Health/kbm-ledsas-sdk/tree/main/examples/hello_world_service) for a complete,
|
|
116
|
+
runnable service (handler, sender script, tests, `Dockerfile`, and a local
|
|
117
|
+
`docker compose` stack under `deploy/local/`).
|
|
118
|
+
|
|
119
|
+
## Configuration
|
|
120
|
+
|
|
121
|
+
The SDK is configured through environment variables. The most common are below; see the [API reference](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/docs/SDK_API_REFERENCE.md#environment-variables) for the complete list (including `KBM_LEDSAS_ALLOW_INSECURE_AMQP`, `KBM_LEDSAS_MAX_PAYLOAD_BYTES`, and other advanced settings):
|
|
122
|
+
|
|
123
|
+
| Variable | Description | Default |
|
|
124
|
+
|----------|-------------|---------|
|
|
125
|
+
| `KBM_LEDSAS_SERVICE_NAME` | Service name used for message routing | *(required)* |
|
|
126
|
+
| `KBM_LEDSAS_TENANT` | Tenant identifier | *(optional)* |
|
|
127
|
+
| `KBM_LEDSAS_RABBITMQ_URL` | RabbitMQ connection URL | *(required)* |
|
|
128
|
+
| `KBM_LEDSAS_BLOB_CONN_STRING` | Azure Blob Storage connection string | *(required)* |
|
|
129
|
+
| `KBM_LEDSAS_CONTAINER` | Default blob container | `dev` |
|
|
130
|
+
| `KBM_LEDSAS_PREFETCH` | AMQP prefetch count | `10` |
|
|
131
|
+
| `KBM_LEDSAS_CONCURRENCY` | Worker concurrency | `4` |
|
|
132
|
+
| `KBM_LEDSAS_HANDLER_TIMEOUT` | Per-handler timeout (seconds) | `1800` |
|
|
133
|
+
| `KBM_LEDSAS_MAX_RETRIES` | Max retries for transient failures | `3` |
|
|
134
|
+
| `KBM_LEDSAS_LOG_LEVEL` | Log level | `INFO` |
|
|
135
|
+
| `KBM_LEDSAS_LOG_FORMAT` | Log format (`json` or `text`) | `json` |
|
|
136
|
+
| `KBM_LEDSAS_HEALTH_HOST` | Health server bind host | `127.0.0.1` |
|
|
137
|
+
| `KBM_LEDSAS_HEALTH_PORT` | Health server port | `8090` |
|
|
138
|
+
| `KBM_LEDSAS_DEPLOYMENT_ID` | Build/commit id surfaced as `deployment_id` in `/health` and `/ready` | *(optional)* |
|
|
139
|
+
|
|
140
|
+
## Documentation
|
|
141
|
+
|
|
142
|
+
- [API Reference](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/docs/SDK_API_REFERENCE.md)
|
|
143
|
+
- [Example service](https://github.com/Kubyk-Health/kbm-ledsas-sdk/tree/main/examples/hello_world_service)
|
|
144
|
+
- [Changelog](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/CHANGELOG.md)
|
|
145
|
+
|
|
146
|
+
## Contributing
|
|
147
|
+
|
|
148
|
+
Contributions are welcome! Please read [CONTRIBUTING.md](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/CONTRIBUTING.md) first — it covers
|
|
149
|
+
the development setup, how to run the tests, the coding style, and the **Developer Certificate
|
|
150
|
+
of Origin (DCO)** sign-off we require on every commit. Also see our
|
|
151
|
+
[Code of Conduct](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/CODE_OF_CONDUCT.md).
|
|
152
|
+
|
|
153
|
+
## Security
|
|
154
|
+
|
|
155
|
+
Please report vulnerabilities privately — see [SECURITY.md](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/SECURITY.md). Do **not** open a
|
|
156
|
+
public issue for security reports.
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
Licensed under the [Apache License 2.0](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/LICENSE). Copyright © 2025-2026 KeborMed.
|
|
161
|
+
See [THIRD_PARTY_NOTICES.txt](https://github.com/Kubyk-Health/kbm-ledsas-sdk/blob/main/THIRD_PARTY_NOTICES.txt) for third-party dependency licenses.
|
|
162
|
+
|
|
163
|
+
Maintained by **KeborMed** (the software's copyright holder) under the
|
|
164
|
+
[**Kubyk-Health**](https://github.com/Kubyk-Health) GitHub organization.
|