bharatml_commons
Common utilities and protobuf definitions for BharatML Stack.
Overview
bharatml_commons provides shared utilities, protobuf definitions, and base classes used across all BharatML Stack Python SDKs. This package serves as the foundation for other BharatML Stack components.
Features
- Protobuf Schemas: Shared persist.proto and retrieve.proto definitions
- HTTP Clients: REST API client utilities with authentication
- Feature Metadata Client: Complete REST API client for metadata operations
- Data Processing: Column and feature processing utilities
- Base SDK Classes: Consistent API design across all clients
- Code Generation: Scripts for protobuf Python file generation
Installation
pip install bharatml_commons
Quick Start
Feature Metadata Client
from bharatml_commons import FeatureMetadataClient
# Initialize client
client = FeatureMetadataClient(
metadata_url="https://api.example.com",
job_id="my-job",
job_token="my-token"
)
# Get feature metadata
metadata = client.get_feature_metadata(["user_features"])
features = client.get_features({"user_id": "123"}, ["user_features"])
HTTP Client Utilities
from bharatml_commons import BharatMLHTTPClient
# Low-level HTTP client
client = BharatMLHTTPClient()
response = client.get("https://api.example.com/health")
Column and Feature Utilities
from bharatml_commons import clean_column_name, get_fgs_to_feature_mappings
# Clean column names
clean_name = clean_column_name("feature@name#1")
# Output: "feature_name_1"
# Process feature mappings
mappings = get_fgs_to_feature_mappings(feature_groups_data)
Protobuf Definitions
from bharatml_commons.proto.persist.persist_pb2 import Query, Data
from bharatml_commons.proto.retrieve.retrieve_pb2 import RetrieveQuery
# Use protobuf messages
query = Query(entity_label="user", keys_schema=["user_id"])
API Reference
FeatureMetadataClient
The main client for interacting with feature metadata APIs.
class FeatureMetadataClient:
def __init__(self, metadata_url: str, job_id: str, job_token: str)
def get_feature_metadata(self, feature_groups: List[str]) -> Dict
def get_features(self, entity_keys: Dict, feature_groups: List[str]) -> Dict
def health_check() -> Dict
Utility Functions
clean_column_name(name: str) -> str: Clean and normalize column namesgenerate_renamed_column(old_name: str, new_name: str) -> str: Generate renamed columnsget_fgs_to_feature_mappings(data: Dict) -> Dict: Process feature group mappingsextract_entity_info(metadata: Dict) -> Tuple: Extract entity information
HTTP Client
class BharatMLHTTPClient:
def get(self, url: str, headers: Dict = None) -> Dict
def post(self, url: str, data: Dict, headers: Dict = None) -> Dict
def put(self, url: str, data: Dict, headers: Dict = None) -> Dict
def delete(self, url: str, headers: Dict = None) -> Dict
Development
Setting up Development Environment
git clone https://github.com/Meesho/BharatMLStack.git
cd BharatMLStack/py-sdk/bharatml_commons
pip install -e .
Running Tests
pytest tests/ -v
Generating Protobuf Files
python -m bharatml_commons.proto.generate_proto
Related Packages
This package is part of the BharatML Stack ecosystem:
- spark_feature_push_client: Spark-based data pipeline client
- grpc_feature_client: High-performance gRPC client for real-time operations
Contributing
We welcome contributions from the community! Please see our Contributing Guide for details on how to get started.
Community & Support
- 💬 Discord: Join our community chat
- 🐛 Issues: Report bugs and request features on GitHub Issues
- 📧 Email: Contact us at ml-oss@meesho.com
License
BharatMLStack is open-source software licensed under the BharatMLStack Business Source License 1.1.
Metadata
Release files for bharatml-commons 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| bharatml_commons-1.0.1.tar.gz | 12.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bharatml_commons-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.8 kB
Release files / bharatml_commons-1.0.1.tar.gz
| Download URL | bharatml_commons-1.0.1.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd6865455d760e4511223838fd8474340fca294d63ec66ead89a494d3f7c789c
|
|
BLAKE2b-256 checksum How to use checksums |
e9a951831ae79f7d9e3d45d2f9a3ec0e4ef276ac6b3254e93bcedd67a529dc46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Release files / bharatml_commons-1.0.1-py3-none-any.whl
| Download URL | bharatml_commons-1.0.1-py3-none-any.whl |
|---|---|
| Size | 18.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
383efeaa165df56c8a15aeca9413cb39643956c5e5c34bced9d3c5f89b24606e
|
|
BLAKE2b-256 checksum How to use checksums |
6ac098db114cc8dd62f5b417624b99345e8fccb9028695037bf78b3515648d7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Security for bharatml-commons 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.