bw-essentials-core 0.0.1__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.
Potentially problematic release.
This version of bw-essentials-core might be problematic. Click here for more details.
- bw_essentials/__init__.py +0 -0
- bw_essentials/constants/__init__.py +0 -0
- bw_essentials/constants/services.py +19 -0
- bw_essentials/data_loch/__init__.py +0 -0
- bw_essentials/data_loch/data_loch.py +282 -0
- bw_essentials/email_client/__init__.py +0 -0
- bw_essentials/email_client/email_client.py +243 -0
- bw_essentials/notifications/__init__.py +0 -0
- bw_essentials/notifications/teams_notification_schemas.py +173 -0
- bw_essentials/notifications/teams_notifications.py +189 -0
- bw_essentials/s3_utils/__init__.py +0 -0
- bw_essentials/s3_utils/s3_utils.py +361 -0
- bw_essentials/services/__init__.py +0 -0
- bw_essentials/services/api_client.py +229 -0
- bw_essentials/services/broker.py +250 -0
- bw_essentials/services/market_pricer.py +233 -0
- bw_essentials/services/master_data.py +257 -0
- bw_essentials/services/model_portfolio_reporting.py +81 -0
- bw_essentials/services/trade_placement.py +499 -0
- bw_essentials/services/user_portfolio.py +406 -0
- bw_essentials/services/user_portfolio_reporting.py +153 -0
- bw_essentials_core-0.0.1.dist-info/METADATA +213 -0
- bw_essentials_core-0.0.1.dist-info/RECORD +25 -0
- bw_essentials_core-0.0.1.dist-info/WHEEL +5 -0
- bw_essentials_core-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bw-essentials-core
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Reusable utilities for S3, email, Data Loch, Microsoft Teams Notifications and more.
|
|
5
|
+
Author: InvestorAI
|
|
6
|
+
Author-email: support+tech@investorai.in
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: boto3~=1.37.30
|
|
15
|
+
Requires-Dist: botocore~=1.37.30
|
|
16
|
+
Requires-Dist: lakefs~=0.9.1
|
|
17
|
+
Requires-Dist: requests~=2.32.3
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: author-email
|
|
20
|
+
Dynamic: classifier
|
|
21
|
+
Dynamic: description
|
|
22
|
+
Dynamic: description-content-type
|
|
23
|
+
Dynamic: requires-dist
|
|
24
|
+
Dynamic: requires-python
|
|
25
|
+
Dynamic: summary
|
|
26
|
+
|
|
27
|
+
# bw-essentials
|
|
28
|
+
|
|
29
|
+
Hereβs a rephrased version of your description with improved flow and clarity:
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
**`bw-essentials`** is a Python utility package offering modular and production-ready wrappers for core infrastructure tasks. It simplifies operations such as **AWS S3 interactions**, **email notifications**, and **version-controlled data lake workflows using LakeFS**. Designed for flexibility and ease of integration, it's well-suited for use across microservices, data pipelines, and automation frameworks.
|
|
34
|
+
|
|
35
|
+
In addition to infrastructure utilities, it also includes service-specific wrappers for:
|
|
36
|
+
|
|
37
|
+
1. Master Data
|
|
38
|
+
2. Market Pricer
|
|
39
|
+
3. Broker
|
|
40
|
+
4. Model Portfolio Reporting
|
|
41
|
+
5. Trade Placement
|
|
42
|
+
6. User Portfolio
|
|
43
|
+
7. User Portfolio Reporting
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## π¦ Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install bw-essentials
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## π S3Utils
|
|
56
|
+
|
|
57
|
+
`S3Utils` provides a high-level interface to interact with AWS S3 and S3-compatible services like MinIO or LocalStack.
|
|
58
|
+
|
|
59
|
+
### π§ Initialization
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from bw_essentials.s3_utils import S3Utils
|
|
63
|
+
|
|
64
|
+
s3 = S3Utils()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### β
Available Methods
|
|
68
|
+
|
|
69
|
+
| Method | Description |
|
|
70
|
+
|---------------------------------------------------------------|-----------------------------------------------|
|
|
71
|
+
| `upload_file(bucket, key, file_path)` | Upload a local file to S3 |
|
|
72
|
+
| `download_file(bucket, key, dest_path)` | Download a file from S3 |
|
|
73
|
+
| `list_files(bucket, prefix="")` | List all files under a prefix |
|
|
74
|
+
| `read_file(bucket, key)` | Read and return the content of a file |
|
|
75
|
+
| `delete_file(bucket, key)` | Delete a specific file |
|
|
76
|
+
| `file_exists(bucket, key)` | Check if a file exists |
|
|
77
|
+
| `get_latest_file(bucket, prefix)` | Get the latest file by modified time |
|
|
78
|
+
| `sync_local_to_s3(bucket, prefix, local_path)` | Recursively upload a local directory to S3 |
|
|
79
|
+
| `sync_s3_to_local(bucket, prefix, local_path)` | Recursively download an S3 prefix to local |
|
|
80
|
+
| `generate_presigned_url(bucket_name, object_key, expiration)` | Generates Pre Signed Url for given S3 Object. |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## π¬ EmailClient
|
|
85
|
+
|
|
86
|
+
`EmailClient` helps send email notifications with or without attachments using any SMTP server.
|
|
87
|
+
|
|
88
|
+
### π§ Initialization
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from bw_essentials.email_client import EmailClient
|
|
92
|
+
|
|
93
|
+
client = EmailClient(
|
|
94
|
+
sender_email="noreply@example.com",
|
|
95
|
+
sender_name="BW Notifier"
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### β
Available Methods
|
|
100
|
+
|
|
101
|
+
| Method | Description |
|
|
102
|
+
|--------|-------------|
|
|
103
|
+
| `send_email_without_attachment(to_addresses, cc_addresses, subject, body, is_html=True)` | Send an email without attachment |
|
|
104
|
+
| `send_email_with_attachment(to_addresses, cc_addresses, subject, body, attachment_path, is_html=True)` | Send an email with a file attachment |
|
|
105
|
+
|
|
106
|
+
- Supports both plain text and HTML.
|
|
107
|
+
- Accepts single or multiple recipients (`str` or `List[str]`).
|
|
108
|
+
- Gracefully handles invalid paths and logs detailed errors.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## ποΈ DataLoch (LakeFS Wrapper)
|
|
113
|
+
|
|
114
|
+
`DataLoch` wraps LakeFS Python client for working with versioned data over S3. Useful for managing commits, branches, and file operations in a data lake.
|
|
115
|
+
|
|
116
|
+
### π§ Initialization
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from bw_essentials.data_loch import LakeFS
|
|
120
|
+
|
|
121
|
+
dl = LakeFS()
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
You can pass `branch` and `repo` to individual methods or initialize them via `dl.repo = "repo"` and `dl.branch = "branch"`.
|
|
125
|
+
|
|
126
|
+
### β
Available Methods
|
|
127
|
+
|
|
128
|
+
| Method | Description |
|
|
129
|
+
|--------|-------------|
|
|
130
|
+
| `upload_file(local_path, repo, branch, dest_path)` | Upload a single file to a branch |
|
|
131
|
+
| `download_file(repo, branch, file_path, dest_path)` | Download a single file |
|
|
132
|
+
| `sync_local_to_lakefs(local_path, repo, branch, dest_prefix)` | Recursively upload a directory |
|
|
133
|
+
| `sync_lakefs_to_local(repo, branch, src_prefix, local_path)` | Recursively download a directory |
|
|
134
|
+
| `commit(repo, branch, message)` | Commit the current changes on a branch |
|
|
135
|
+
| `get_latest_file(repo, branch, prefix)` | Get latest file (by time) under a prefix |
|
|
136
|
+
| `delete_file(repo, branch, file_path)` | Delete a specific file |
|
|
137
|
+
|
|
138
|
+
- Supports S3-compatible object storage behind LakeFS.
|
|
139
|
+
- Handles versioning and commit messages for reproducibility.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## π§ͺ Example Use Case
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
# Send notification with S3 report
|
|
147
|
+
from bw_essentials.s3_utils import S3Utils
|
|
148
|
+
from bw_essentials.email_client import EmailClient
|
|
149
|
+
|
|
150
|
+
s3 = S3Utils("AK", "SK")
|
|
151
|
+
file_path = "/tmp/report.csv"
|
|
152
|
+
s3.download_file("my-bucket", "reports/weekly.csv", file_path)
|
|
153
|
+
|
|
154
|
+
email_client = EmailClient("me@example.com", "Report Bot")
|
|
155
|
+
email_client.send_email_with_attachment(
|
|
156
|
+
to_addresses="client@example.com",
|
|
157
|
+
cc_addresses=["ops@example.com"],
|
|
158
|
+
subject="Weekly Report",
|
|
159
|
+
body="<h1>Attached is your report</h1>",
|
|
160
|
+
attachment_path=file_path
|
|
161
|
+
)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Hereβs the updated `setup.py` with a module docstring and updated dependencies:
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
## π Notifications
|
|
169
|
+
|
|
170
|
+
`Notifications` helps send structured alerts and logs to external communication tools like **Microsoft Teams** and **Zenduty**. Ideal for operational awareness and incident response workflows.
|
|
171
|
+
|
|
172
|
+
### π§ Initialization
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from bw_essentials.notifications import Notifications
|
|
176
|
+
|
|
177
|
+
notifier = Notifications(
|
|
178
|
+
title="BW Alerts",
|
|
179
|
+
summary="Pipeline Failure",
|
|
180
|
+
message="Daily data sync failed."
|
|
181
|
+
)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### β
Available Methods
|
|
185
|
+
|
|
186
|
+
| Method | Description |
|
|
187
|
+
|--------|-------------|
|
|
188
|
+
| `notify_message(message=None, summary=None, alert=False)` | Send a general log message to Teams |
|
|
189
|
+
| `notify_error(message=None, summary=None, alert=True, trace=None, request_id=None)` | Send an error alert to Teams and Zenduty |
|
|
190
|
+
|
|
191
|
+
- Automatically uses different formats for logs vs. alerts.
|
|
192
|
+
- Teams messages are sent via Adaptive Cards.
|
|
193
|
+
- Zenduty alerts include critical summaries and tracebacks.
|
|
194
|
+
- You can override the default `message`, `summary`, `trace`, and `request_id` per notification.
|
|
195
|
+
|
|
196
|
+
### π Example Use Case
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
notifier.notify_error(
|
|
200
|
+
message="ETL job failed due to timeout.",
|
|
201
|
+
summary="Job: daily-prices-sync",
|
|
202
|
+
trace="Traceback (most recent call last): ...",
|
|
203
|
+
request_id="req-123abc"
|
|
204
|
+
)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
Let me know if you'd like a logo badge, GitHub Actions setup, or example `.whl` build as well.
|
|
210
|
+
|
|
211
|
+
## π¬ Contact
|
|
212
|
+
|
|
213
|
+
For bugs or feature requests, open an issue or contact [support+tech@investorai.in](mailto:your-email@example.com)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
bw_essentials/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
bw_essentials/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
bw_essentials/constants/services.py,sha256=ZRz-cfumqafmAsetW48S3KMTjTaNAdoV1zu3bRuYfNc,513
|
|
4
|
+
bw_essentials/data_loch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
bw_essentials/data_loch/data_loch.py,sha256=NUVNvveyvHe70JFmyCd9loHC-XRm5aota5rD5xhx4Eo,11128
|
|
6
|
+
bw_essentials/email_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
bw_essentials/email_client/email_client.py,sha256=_LzDWUJUkNTSn3C5v0-jjW-Ls537xt493lkcD4noQXY,9116
|
|
8
|
+
bw_essentials/notifications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
bw_essentials/notifications/teams_notification_schemas.py,sha256=FvZ8FyIwku4-0uweDn9gpaIJW_AIsNoqV1hB6lQ4OPI,6398
|
|
10
|
+
bw_essentials/notifications/teams_notifications.py,sha256=tgDSOoAeNlhIq2ZJGTzf99bMEBajXe0rdCb9JJkm0ss,6913
|
|
11
|
+
bw_essentials/s3_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
bw_essentials/s3_utils/s3_utils.py,sha256=jYjFR4rOe3MT0wk7jvqI7itOH4hNDw7CmbPUlIf2coc,13104
|
|
13
|
+
bw_essentials/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
bw_essentials/services/api_client.py,sha256=2aTysB4AfHqCILz2o4qOb5Z-GK5GtzhmFe3NFUfAsto,7793
|
|
15
|
+
bw_essentials/services/broker.py,sha256=As-VT1MxkCD9p-13dQJDwf0_aEJVA6H0wNqL-EYHO4g,8718
|
|
16
|
+
bw_essentials/services/market_pricer.py,sha256=WAFcG5JfnqWxjzXRPrMdovPuKqWJIwa3ENvGAyEyjeM,8712
|
|
17
|
+
bw_essentials/services/master_data.py,sha256=tJ-OyG9j94Piw2-rByhvkz6aVds4t6b5aprkT1TUPJQ,10068
|
|
18
|
+
bw_essentials/services/model_portfolio_reporting.py,sha256=iOtm4gyfU8P7C0R1gp6gUJI4ZRxJD5K2GLOalI_gToM,3249
|
|
19
|
+
bw_essentials/services/trade_placement.py,sha256=PrzeU2XXC9HF1IQ1dMDM_ZHxmC491sOl-JbA6GWPwII,20772
|
|
20
|
+
bw_essentials/services/user_portfolio.py,sha256=_5M6yPfQt4MXedINBawEoPkb_o7IGzxPeHkvZkoQm8k,16191
|
|
21
|
+
bw_essentials/services/user_portfolio_reporting.py,sha256=QaZzcw912Uos5ZafEaxLXDmCyetTFiVX3at3cTAv6MA,6003
|
|
22
|
+
bw_essentials_core-0.0.1.dist-info/METADATA,sha256=BFj2cdo6JmYhFtYSobq-ExTxiUqNoeujisW9Drv3Hho,7455
|
|
23
|
+
bw_essentials_core-0.0.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
24
|
+
bw_essentials_core-0.0.1.dist-info/top_level.txt,sha256=gDc5T_y5snwKGXDQUusEus-FEt0RFwG644Yn_58wQOQ,14
|
|
25
|
+
bw_essentials_core-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bw_essentials
|