High-performance gRPC client for BharatML Stack real-time feature operations
Project description
grpc_feature_client
High-performance gRPC client for BharatML Stack real-time feature operations with direct API access.
Installation
pip install grpc_feature_client
Dependencies
This package depends on:
- bharatml_commons: Common utilities and protobuf definitions
- grpcio>=1.50.0: gRPC framework
- grpcio-tools>=1.50.0: gRPC tools for protobuf
Features
- Direct gRPC API: persist, retrieve, retrieveDecoded operations
- Go SDK Compatible: Same authentication and API semantics
- Batch Processing: Automatic batching with parallel execution
- Real-time Focus: Low-latency feature persistence and retrieval
- Context Management: Timeout and metadata handling
- Connection Pooling: Efficient connection management
Quick Start
from grpc_feature_client import GRPCFeatureClient, GRPCClientConfig
# Configure for real-time operations
config = GRPCClientConfig(
server_address="localhost:50051",
job_id="realtime-service",
job_token="api-token"
)
client = GRPCFeatureClient(config)
# Direct API operations
result = client.persist_features(entity_label, keys_schema, feature_groups, data)
features = client.retrieve_decoded_features(entity_label, feature_groups, keys, entity_keys)
API Reference
GRPCFeatureClient
class GRPCFeatureClient:
def __init__(self, config: GRPCClientConfig)
def persist_features(
self,
entity_label: str,
keys_schema: List[str],
feature_group_schemas: List[Dict[str, Any]],
data_rows: List[Dict[str, Any]],
timeout: Optional[float] = None
) -> Dict[str, Any]
def retrieve_features(
self,
entity_label: str,
feature_groups: List[Dict[str, Any]],
keys_schema: List[str],
entity_keys: List[List[str]],
timeout: Optional[float] = None
) -> Dict[str, Any]
def retrieve_decoded_features(
self,
entity_label: str,
feature_groups: List[Dict[str, Any]],
keys_schema: List[str],
entity_keys: List[List[str]],
timeout: Optional[float] = None
) -> Dict[str, Any]
GRPCClientConfig
class GRPCClientConfig:
def __init__(
self,
server_address: str,
job_id: str,
job_token: str,
use_tls: bool = False,
timeout_seconds: float = 30.0,
metadata: Dict[str, str] = None,
max_receive_message_length: int = 4 * 1024 * 1024,
max_send_message_length: int = 4 * 1024 * 1024
)
Usage Examples
Persisting Features
from grpc_feature_client import GRPCFeatureClient, GRPCClientConfig
config = GRPCClientConfig(
server_address="feature-store.example.com:50051",
job_id="model-inference-service",
job_token="api-token"
)
client = GRPCFeatureClient(config)
# Persist real-time features
result = client.persist_features(
entity_label="user_interaction",
keys_schema=["user_id", "session_id"],
feature_group_schemas=[{
"label": "realtime_features",
"feature_labels": ["click_count", "page_views"]
}],
data_rows=[{
"user_id": "u123",
"session_id": "s456",
"click_count": 5,
"page_views": 3
}]
)
print(f"Persist result: {result}")
Retrieving Features
# Retrieve features for ML model inference
features = client.retrieve_decoded_features(
entity_label="user_interaction",
feature_groups=[{
"label": "user_features",
"feature_labels": ["age", "location"]
}],
keys_schema=["user_id"],
entity_keys=[["u123"], ["u456"]]
)
print(f"Retrieved features: {features}")
With Context Management
# Use client with automatic cleanup
with GRPCFeatureClient(config) as client:
result = client.persist_features(...)
features = client.retrieve_decoded_features(...)
# Connection automatically closed
When to Use
Use grpc_feature_client for:
- 🚀 Real-time Operations: Direct persist/retrieve operations
- 🔍 Interactive Queries: Low-latency feature lookups
- 🎯 API Integration: Service-to-service communication
- 💨 Single Records: Persisting individual feature records
- 🔄 Model Serving: Feature retrieval for online inference
Use spark_feature_push_client for:
- 🔄 Batch ETL Pipelines: Scheduled feature computation and publishing
- 📊 Historical Data Backfill: Loading historical features into online store
- 🏗️ Data Engineering: Spark-based feature transformations
- 📈 Large Scale Processing: Processing millions of records efficiently
Related Packages
This package is part of the BharatML Stack ecosystem:
- bharatml_commons: Common utilities and protobuf definitions (required dependency)
- spark_feature_push_client: Spark-based data pipeline client
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grpc_feature_client-1.0.1.tar.gz.
File metadata
- Download URL: grpc_feature_client-1.0.1.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74abf9bff4bd5791a1818293494fe82626b8d86aba159279c7cd385aa1eecd50
|
|
| MD5 |
321e200ff8086eeeadeda55868160b34
|
|
| BLAKE2b-256 |
5f3ec5392829c43fb398bb4b08c4df8258323a56301fcbad59713411ba35af27
|
File details
Details for the file grpc_feature_client-1.0.1-py3-none-any.whl.
File metadata
- Download URL: grpc_feature_client-1.0.1-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6928750cce2e1ab8a50b0e9bcf2dc6574c626f07fb5d42b82a556d3c1a1966e9
|
|
| MD5 |
bab799c5e05e4e18e72cb4b876f4095e
|
|
| BLAKE2b-256 |
9864710b5987df32937330e91ee00de39a0ac0d0c93c65472700bdb8550edb1e
|