Python SDK
Status: In development
The Python SDK provides a high-level API for managing infrastructure with Senren.
Installation
Quick Start
from senren import SenrenClient, Database
# Connect to control plane
client = SenrenClient(endpoint="control.senren.dev")
# Define infrastructure
client.apply_state(
databases=[
Database(
name="user-cache",
type="redis-cluster",
memory_mb=8192,
regions=["aws:us-east-1", "gcp:us-central1"],
)
]
)
# Query status
status = client.get_status("user-cache")
print(f"Ready: {status.ready}")
API Reference
SenrenClient
Constructor:
SenrenClient(
endpoint: str, # Control plane gRPC endpoint
timeout_seconds: int = 30, # Request timeout
)
Methods:
apply_state()
Apply desired infrastructure state.
client.apply_state(
databases: list[Database] = [],
# feature_stores: list[FeatureStore] = [], # Coming soon
# search_indexes: list[SearchIndex] = [], # Coming soon
) -> ApplyResponse
Returns:
- ApplyResponse with applied_version field
get_status()
Get status of a specific resource.
Returns:
- ResourceStatus with fields:
- ready: bool - Whether resource is ready
- host: str - Connection host
- port: int - Connection port
- error: str | None - Error message if not ready
Database
Constructor:
Database(
name: str, # Unique name
type: str, # "redis" | "redis-cluster" | "dragonfly"
memory_mb: int, # Memory allocation in MB
regions: list[str], # List of region identifiers
namespace: str = "default", # Kubernetes namespace
)
Region identifiers:
- AWS: aws:us-east-1, aws:eu-west-1, etc.
- GCP: gcp:us-central1, gcp:europe-west1, etc.
- Multi-cluster: aws:us-east-1:prod, aws:us-east-1:shadow
ResourceStatus
Fields:
@dataclass
class ResourceStatus:
ready: bool # Is the resource ready?
host: str # Connection host
port: int # Connection port
error: str | None # Error message if not ready
Examples
Multi-region Deployment
from senren import SenrenClient, Database
client = SenrenClient(endpoint="control.senren.dev")
# Deploy to 3 regions
client.apply_state(
databases=[
Database(
name="global-cache",
type="redis-cluster",
memory_mb=16384,
regions=[
"aws:us-east-1",
"aws:eu-west-1",
"gcp:asia-east1",
],
)
]
)
Updating Configuration
# Increase memory
client.apply_state(
databases=[
Database(
name="global-cache",
type="redis-cluster",
memory_mb=32768, # Doubled
regions=[
"aws:us-east-1",
"aws:eu-west-1",
"gcp:asia-east1",
],
)
]
)
Removing Resources
Checking Status
import time
status = client.get_status("global-cache")
if status.ready:
print(f"Database ready at {status.host}:{status.port}")
else:
print(f"Database not ready: {status.error}")
# Poll until ready
while not status.ready:
time.sleep(1)
status = client.get_status("global-cache")
Error Handling
from senren import SenrenClient, SenrenError
try:
client.apply_state(databases=[...])
except SenrenError as e:
print(f"Failed to apply state: {e}")
Coming Soon
The following APIs are planned:
Feature Stores (Q2 2025)
from senren import FeatureStore
store = FeatureStore(
name="user-features",
type="online",
backend="redis-cluster",
schema={...},
regions=[...],
)
Search Indexes (Q3 2025)
from senren import SearchIndex
index = SearchIndex(
name="product-search",
type="elasticsearch",
memory_gb=16,
regions=[...],
)
Model Serving (Q4 2025)
from senren import ModelServer
server = ModelServer(
name="recommendation-model",
type="torchserve",
model_url="s3://...",
regions=[...],
)
gRPC API
The Python SDK is a wrapper around the gRPC API. For advanced use cases or other languages, you can use the gRPC API directly (documentation coming soon).