Skip to main content

bw-essentials

Here’s a rephrased version of your description with improved flow and clarity:


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.

In addition to infrastructure utilities, it also includes service-specific wrappers for:

  1. Master Data
  2. Market Pricer
  3. Broker
  4. Model Portfolio Reporting
  5. Trade Placement
  6. User Portfolio
  7. User Portfolio Reporting

📦 Installation

pip install bw-essentials

📁 S3Utils

S3Utils provides a high-level interface to interact with AWS S3 and S3-compatible services like MinIO or LocalStack.

🔧 Initialization

from bw_essentials.s3_utils import S3Utils

s3 = S3Utils()

✅ Available Methods

Method Description
upload_file(bucket, key, file_path) Upload a local file to S3
download_file(bucket, key, dest_path) Download a file from S3
list_files(bucket, prefix="") List all files under a prefix
read_file(bucket, key) Read and return the content of a file
delete_file(bucket, key) Delete a specific file
file_exists(bucket, key) Check if a file exists
get_latest_file(bucket, prefix) Get the latest file by modified time
sync_local_to_s3(bucket, prefix, local_path) Recursively upload a local directory to S3
sync_s3_to_local(bucket, prefix, local_path) Recursively download an S3 prefix to local
generate_presigned_url(bucket_name, object_key, expiration) Generates Pre Signed Url for given S3 Object.

📬 EmailClient

EmailClient helps send email notifications with or without attachments using any SMTP server.

🔧 Initialization

from bw_essentials.email_client import EmailClient

client = EmailClient(
    sender_email="noreply@example.com",
    sender_name="BW Notifier"
)

✅ Available Methods

Method Description
send_email_without_attachment(to_addresses, cc_addresses, subject, body, is_html=True) Send an email without attachment
send_email_with_attachment(to_addresses, cc_addresses, subject, body, attachment_path, is_html=True) Send an email with a file attachment
  • Supports both plain text and HTML.
  • Accepts single or multiple recipients (str or List[str]).
  • Gracefully handles invalid paths and logs detailed errors.

🏞️ DataLoch (LakeFS Wrapper)

DataLoch wraps LakeFS Python client for working with versioned data over S3. Useful for managing commits, branches, and file operations in a data lake.

🔧 Initialization

from bw_essentials.data_loch import LakeFS

dl = LakeFS()

You can pass branch and repo to individual methods or initialize them via dl.repo = "repo" and dl.branch = "branch".

✅ Available Methods

Method Description
upload_file(local_path, repo, branch, dest_path) Upload a single file to a branch
download_file(repo, branch, file_path, dest_path) Download a single file
sync_local_to_lakefs(local_path, repo, branch, dest_prefix) Recursively upload a directory
sync_lakefs_to_local(repo, branch, src_prefix, local_path) Recursively download a directory
commit(repo, branch, message) Commit the current changes on a branch
get_latest_file(repo, branch, prefix) Get latest file (by time) under a prefix
delete_file(repo, branch, file_path) Delete a specific file
  • Supports S3-compatible object storage behind LakeFS.
  • Handles versioning and commit messages for reproducibility.

🧪 Example Use Case

# Send notification with S3 report
from bw_essentials.s3_utils import S3Utils
from bw_essentials.email_client import EmailClient

s3 = S3Utils("AK", "SK")
file_path = "/tmp/report.csv"
s3.download_file("my-bucket", "reports/weekly.csv", file_path)

email_client = EmailClient("me@example.com", "Report Bot")
email_client.send_email_with_attachment(
    to_addresses="client@example.com",
    cc_addresses=["ops@example.com"],
    subject="Weekly Report",
    body="<h1>Attached is your report</h1>",
    attachment_path=file_path
)

Here’s the updated setup.py with a module docstring and updated dependencies:

🔔 Notifications

Notifications helps send structured alerts and logs to external communication tools like Microsoft Teams and Zenduty. Ideal for operational awareness and incident response workflows.

🔧 Initialization

from bw_essentials.notifications import Notifications

notifier = Notifications(
    title="BW Alerts",
    summary="Pipeline Failure",
    message="Daily data sync failed.",
    webhook_url="https://sample.webhook.url"
)

✅ Available Methods

Method Description
notify_message(message=None, summary=None, alert=False) Send a general log message to Teams
notify_error(message=None, summary=None, alert=True, trace=None, request_id=None) Send an error alert to Teams and Zenduty
  • Automatically uses different formats for logs vs. alerts.
  • Teams messages are sent via Adaptive Cards.
  • Zenduty alerts include critical summaries and tracebacks.
  • You can override the default message, summary, trace, and request_id per notification.

📘 Example Use Case

notifier.notify_error(
    message="ETL job failed due to timeout.",
    summary="Job: daily-prices-sync",
    trace="Traceback (most recent call last): ...",
    request_id="req-123abc"
)

Let me know if you'd like a logo badge, GitHub Actions setup, or example .whl build as well.

📬 Contact

For bugs or feature requests, open an issue or contact support+tech@investorai.in

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bw_essentials_core-0.1.82.tar.gz (74.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bw_essentials_core-0.1.82-py3-none-any.whl (86.0 kB view details)

Uploaded Python 3

File details

Details for the file bw_essentials_core-0.1.82.tar.gz.

File metadata

  • Download URL: bw_essentials_core-0.1.82.tar.gz
  • Upload date:
  • Size: 74.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for bw_essentials_core-0.1.82.tar.gz
Algorithm Hash digest
SHA256 c9290d38f6a6415ebe362a21646dbe4077207a0fde1520de72a40a82a83574c6
MD5 8d91386bd898cd7681e4b1b97202a137
BLAKE2b-256 aa6b081ea9ccb0f7ff3fe73587484d6b0484a32654f586ac10cc3048c6bf504d

See more details on using hashes here.

File details

Details for the file bw_essentials_core-0.1.82-py3-none-any.whl.

File metadata

File hashes

Hashes for bw_essentials_core-0.1.82-py3-none-any.whl
Algorithm Hash digest
SHA256 dd84bbf2b1c2b8462e9cf2e5eceb8dbdf5532eddd36604c08f819317de194af7
MD5 b0bd72d14878ad1bd715db48d73e6fc5
BLAKE2b-256 4891bd920c3f51cc2e0f1a2d4f963a7c0d92fe5c94dbafa59edd75a3a856f7b1

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.85

2 files

0.1.84

2 files

0.1.83

2 files

This release

0.1.82 This release

2 files

0.1.81

2 files

0.1.80

2 files

0.1.79

2 files

0.1.78

2 files

0.1.77

2 files

0.1.76

2 files

0.1.75

2 files

0.1.74

2 files

0.1.73

2 files

0.1.72

2 files

0.1.71

2 files

0.1.70

2 files

0.1.69

2 files

0.1.68

2 files

0.1.67

2 files

0.1.66

2 files

0.1.65

2 files

0.1.64

2 files

0.1.63

2 files

0.1.62

2 files

0.1.61

2 files

0.1.60

2 files

0.1.59

2 files

0.1.58

2 files

0.1.57

2 files

0.1.56

2 files

0.1.55

2 files

0.1.54

2 files

0.1.53

2 files

0.1.52

2 files

0.1.51

2 files

0.1.50

2 files

0.1.49

2 files

0.1.47

2 files

0.1.46

2 files

0.1.45

2 files

0.1.44

2 files

0.1.43

2 files

0.1.42

2 files

0.1.40

2 files

0.1.39

2 files

0.1.35

2 files

0.1.34

2 files

0.1.33

2 files

0.1.32

2 files

0.1.31

2 files

0.1.29

2 files

0.1.28

2 files

0.1.27

2 files

0.1.26

2 files

0.1.25

2 files

0.1.24

2 files

0.1.23

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page