bw-essentials-core 0.0.1__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.

Potentially problematic release.


This version of bw-essentials-core might be problematic. Click here for more details.

Files changed (30) hide show
  1. bw_essentials_core-0.0.1/PKG-INFO +213 -0
  2. bw_essentials_core-0.0.1/README.md +187 -0
  3. bw_essentials_core-0.0.1/bw_essentials/__init__.py +0 -0
  4. bw_essentials_core-0.0.1/bw_essentials/constants/__init__.py +0 -0
  5. bw_essentials_core-0.0.1/bw_essentials/constants/services.py +19 -0
  6. bw_essentials_core-0.0.1/bw_essentials/data_loch/__init__.py +0 -0
  7. bw_essentials_core-0.0.1/bw_essentials/data_loch/data_loch.py +282 -0
  8. bw_essentials_core-0.0.1/bw_essentials/email_client/__init__.py +0 -0
  9. bw_essentials_core-0.0.1/bw_essentials/email_client/email_client.py +243 -0
  10. bw_essentials_core-0.0.1/bw_essentials/notifications/__init__.py +0 -0
  11. bw_essentials_core-0.0.1/bw_essentials/notifications/teams_notification_schemas.py +173 -0
  12. bw_essentials_core-0.0.1/bw_essentials/notifications/teams_notifications.py +189 -0
  13. bw_essentials_core-0.0.1/bw_essentials/s3_utils/__init__.py +0 -0
  14. bw_essentials_core-0.0.1/bw_essentials/s3_utils/s3_utils.py +361 -0
  15. bw_essentials_core-0.0.1/bw_essentials/services/__init__.py +0 -0
  16. bw_essentials_core-0.0.1/bw_essentials/services/api_client.py +229 -0
  17. bw_essentials_core-0.0.1/bw_essentials/services/broker.py +250 -0
  18. bw_essentials_core-0.0.1/bw_essentials/services/market_pricer.py +233 -0
  19. bw_essentials_core-0.0.1/bw_essentials/services/master_data.py +257 -0
  20. bw_essentials_core-0.0.1/bw_essentials/services/model_portfolio_reporting.py +81 -0
  21. bw_essentials_core-0.0.1/bw_essentials/services/trade_placement.py +499 -0
  22. bw_essentials_core-0.0.1/bw_essentials/services/user_portfolio.py +406 -0
  23. bw_essentials_core-0.0.1/bw_essentials/services/user_portfolio_reporting.py +153 -0
  24. bw_essentials_core-0.0.1/bw_essentials_core.egg-info/PKG-INFO +213 -0
  25. bw_essentials_core-0.0.1/bw_essentials_core.egg-info/SOURCES.txt +28 -0
  26. bw_essentials_core-0.0.1/bw_essentials_core.egg-info/dependency_links.txt +1 -0
  27. bw_essentials_core-0.0.1/bw_essentials_core.egg-info/requires.txt +4 -0
  28. bw_essentials_core-0.0.1/bw_essentials_core.egg-info/top_level.txt +1 -0
  29. bw_essentials_core-0.0.1/setup.cfg +4 -0
  30. bw_essentials_core-0.0.1/setup.py +34 -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,187 @@
1
+ # bw-essentials
2
+
3
+ Here’s a rephrased version of your description with improved flow and clarity:
4
+
5
+ ---
6
+
7
+ **`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.
8
+
9
+ In addition to infrastructure utilities, it also includes service-specific wrappers for:
10
+
11
+ 1. Master Data
12
+ 2. Market Pricer
13
+ 3. Broker
14
+ 4. Model Portfolio Reporting
15
+ 5. Trade Placement
16
+ 6. User Portfolio
17
+ 7. User Portfolio Reporting
18
+
19
+ ---
20
+
21
+ ## πŸ“¦ Installation
22
+
23
+ ```bash
24
+ pip install bw-essentials
25
+ ```
26
+
27
+ ---
28
+
29
+ ## πŸ“ S3Utils
30
+
31
+ `S3Utils` provides a high-level interface to interact with AWS S3 and S3-compatible services like MinIO or LocalStack.
32
+
33
+ ### πŸ”§ Initialization
34
+
35
+ ```python
36
+ from bw_essentials.s3_utils import S3Utils
37
+
38
+ s3 = S3Utils()
39
+ ```
40
+
41
+ ### βœ… Available Methods
42
+
43
+ | Method | Description |
44
+ |---------------------------------------------------------------|-----------------------------------------------|
45
+ | `upload_file(bucket, key, file_path)` | Upload a local file to S3 |
46
+ | `download_file(bucket, key, dest_path)` | Download a file from S3 |
47
+ | `list_files(bucket, prefix="")` | List all files under a prefix |
48
+ | `read_file(bucket, key)` | Read and return the content of a file |
49
+ | `delete_file(bucket, key)` | Delete a specific file |
50
+ | `file_exists(bucket, key)` | Check if a file exists |
51
+ | `get_latest_file(bucket, prefix)` | Get the latest file by modified time |
52
+ | `sync_local_to_s3(bucket, prefix, local_path)` | Recursively upload a local directory to S3 |
53
+ | `sync_s3_to_local(bucket, prefix, local_path)` | Recursively download an S3 prefix to local |
54
+ | `generate_presigned_url(bucket_name, object_key, expiration)` | Generates Pre Signed Url for given S3 Object. |
55
+
56
+ ---
57
+
58
+ ## πŸ“¬ EmailClient
59
+
60
+ `EmailClient` helps send email notifications with or without attachments using any SMTP server.
61
+
62
+ ### πŸ”§ Initialization
63
+
64
+ ```python
65
+ from bw_essentials.email_client import EmailClient
66
+
67
+ client = EmailClient(
68
+ sender_email="noreply@example.com",
69
+ sender_name="BW Notifier"
70
+ )
71
+ ```
72
+
73
+ ### βœ… Available Methods
74
+
75
+ | Method | Description |
76
+ |--------|-------------|
77
+ | `send_email_without_attachment(to_addresses, cc_addresses, subject, body, is_html=True)` | Send an email without attachment |
78
+ | `send_email_with_attachment(to_addresses, cc_addresses, subject, body, attachment_path, is_html=True)` | Send an email with a file attachment |
79
+
80
+ - Supports both plain text and HTML.
81
+ - Accepts single or multiple recipients (`str` or `List[str]`).
82
+ - Gracefully handles invalid paths and logs detailed errors.
83
+
84
+ ---
85
+
86
+ ## 🏞️ DataLoch (LakeFS Wrapper)
87
+
88
+ `DataLoch` wraps LakeFS Python client for working with versioned data over S3. Useful for managing commits, branches, and file operations in a data lake.
89
+
90
+ ### πŸ”§ Initialization
91
+
92
+ ```python
93
+ from bw_essentials.data_loch import LakeFS
94
+
95
+ dl = LakeFS()
96
+ ```
97
+
98
+ You can pass `branch` and `repo` to individual methods or initialize them via `dl.repo = "repo"` and `dl.branch = "branch"`.
99
+
100
+ ### βœ… Available Methods
101
+
102
+ | Method | Description |
103
+ |--------|-------------|
104
+ | `upload_file(local_path, repo, branch, dest_path)` | Upload a single file to a branch |
105
+ | `download_file(repo, branch, file_path, dest_path)` | Download a single file |
106
+ | `sync_local_to_lakefs(local_path, repo, branch, dest_prefix)` | Recursively upload a directory |
107
+ | `sync_lakefs_to_local(repo, branch, src_prefix, local_path)` | Recursively download a directory |
108
+ | `commit(repo, branch, message)` | Commit the current changes on a branch |
109
+ | `get_latest_file(repo, branch, prefix)` | Get latest file (by time) under a prefix |
110
+ | `delete_file(repo, branch, file_path)` | Delete a specific file |
111
+
112
+ - Supports S3-compatible object storage behind LakeFS.
113
+ - Handles versioning and commit messages for reproducibility.
114
+
115
+ ---
116
+
117
+ ## πŸ§ͺ Example Use Case
118
+
119
+ ```python
120
+ # Send notification with S3 report
121
+ from bw_essentials.s3_utils import S3Utils
122
+ from bw_essentials.email_client import EmailClient
123
+
124
+ s3 = S3Utils("AK", "SK")
125
+ file_path = "/tmp/report.csv"
126
+ s3.download_file("my-bucket", "reports/weekly.csv", file_path)
127
+
128
+ email_client = EmailClient("me@example.com", "Report Bot")
129
+ email_client.send_email_with_attachment(
130
+ to_addresses="client@example.com",
131
+ cc_addresses=["ops@example.com"],
132
+ subject="Weekly Report",
133
+ body="<h1>Attached is your report</h1>",
134
+ attachment_path=file_path
135
+ )
136
+ ```
137
+
138
+ Here’s the updated `setup.py` with a module docstring and updated dependencies:
139
+
140
+
141
+
142
+ ## πŸ”” Notifications
143
+
144
+ `Notifications` helps send structured alerts and logs to external communication tools like **Microsoft Teams** and **Zenduty**. Ideal for operational awareness and incident response workflows.
145
+
146
+ ### πŸ”§ Initialization
147
+
148
+ ```python
149
+ from bw_essentials.notifications import Notifications
150
+
151
+ notifier = Notifications(
152
+ title="BW Alerts",
153
+ summary="Pipeline Failure",
154
+ message="Daily data sync failed."
155
+ )
156
+ ```
157
+
158
+ ### βœ… Available Methods
159
+
160
+ | Method | Description |
161
+ |--------|-------------|
162
+ | `notify_message(message=None, summary=None, alert=False)` | Send a general log message to Teams |
163
+ | `notify_error(message=None, summary=None, alert=True, trace=None, request_id=None)` | Send an error alert to Teams and Zenduty |
164
+
165
+ - Automatically uses different formats for logs vs. alerts.
166
+ - Teams messages are sent via Adaptive Cards.
167
+ - Zenduty alerts include critical summaries and tracebacks.
168
+ - You can override the default `message`, `summary`, `trace`, and `request_id` per notification.
169
+
170
+ ### πŸ“˜ Example Use Case
171
+
172
+ ```python
173
+ notifier.notify_error(
174
+ message="ETL job failed due to timeout.",
175
+ summary="Job: daily-prices-sync",
176
+ trace="Traceback (most recent call last): ...",
177
+ request_id="req-123abc"
178
+ )
179
+ ```
180
+
181
+ ---
182
+
183
+ Let me know if you'd like a logo badge, GitHub Actions setup, or example `.whl` build as well.
184
+
185
+ ## πŸ“¬ Contact
186
+
187
+ For bugs or feature requests, open an issue or contact [support+tech@investorai.in](mailto:your-email@example.com)
File without changes
@@ -0,0 +1,19 @@
1
+ from enum import Enum
2
+
3
+
4
+ class Services(Enum):
5
+ """
6
+ Enumeration of available services.
7
+ """
8
+ REBALANCE_BUSINESS = 'Rebalance_Business'
9
+ REBALANCE = 'Rebalance'
10
+ MASTER_DATA = 'Master_Data'
11
+ MARKET_PRICER = "Market_Pricer"
12
+ BROKER = 'Broker'
13
+ USER_PORTFOLIO = 'User_Portfolio'
14
+ TRADE_PLACEMENT = 'Trade_Placement'
15
+ CONTENT = 'Portfolio_Content'
16
+ NOTIFICATION = 'Notification'
17
+ USER_REPORTING = 'User_Reporting'
18
+ PAYMENT = 'Payment'
19
+ MODEL_PORTFOLIO = "Model_Portfolio"