Multi-Runtime Standard API for Python
Cloud Runtimes Python provides the Multi-Runtime Standard API for Mecha architecture projects in Python.
This project defines a unified, vendor-neutral API specification that enables Python applications to use standardized interfaces for distributed system capabilities across different runtime implementations.
| Runtime | Status | Description |
|---|---|---|
| Capa | β Used | Primary Mecha SDK implementation |
| Dapr | π Follow | Sidecar runtime reference |
| Layotto | π Follow | MOSN-based sidecar implementation |
cloud-runtimes-python/
βββ cloud_runtimes/ # Core API package
β βββ rpc/ # RPC service invocation
β βββ configuration/ # Configuration management
β βββ pubsub/ # Pub/Sub messaging
β βββ state/ # State management
β βββ secret/ # Secret management
β βββ telemetry/ # Telemetry (logs, metrics, traces)
βββ tests/ # Test suite
βββ docs/ # Documentation
βββ setup.py # Package setup
βββ pyproject.toml # Modern Python packaging
βββ requirements.txt # Dependencies
Key Design Principles:
- API-First: Clean interfaces separate specification from implementation
- Runtime Agnostic: Works with Capa SDK, Dapr, Layotto, and future runtimes
- Pythonic: Follows Python best practices (PEP 8, type hints, async/await)
- Vendor Neutral: No lock-in to specific cloud providers
| Feature | Interface | Description | Status |
|---|---|---|---|
| π Service Invocation | RpcService |
RPC service-to-service communication | β Stable |
| βοΈ Configuration | ConfigurationService |
Dynamic configuration management | β Stable |
| π¨ Pub/Sub | PubSubService |
Publish/Subscribe messaging | β Stable |
| πΎ State Management | StateService |
Key-value state storage | β Stable |
| π Secret Management | SecretService |
Secure secret retrieval | β Stable |
| π Telemetry | TelemetryService |
Logs, metrics, and traces | β Stable |
| π File System | FileService |
File storage operations | β Stable |
| π Distributed Lock | LockService |
Distributed locking | β Stable |
| Feature | Interface | Description | Status |
|---|---|---|---|
| ποΈ Database | DatabaseService |
SQL database operations | π¬ Alpha |
| β° Schedule | ScheduleService |
Scheduled task management | π¬ Alpha |
Cloud Runtimes Python was created to bring standardized, portable APIs to the Python ecosystem:
- Future plans for Dapr API - Community discussion on API standardization
- Make SDK independent - Decoupling API from implementation
- Decompose core and enhanced APIs - API layering strategy
pip install cloud-runtimes-python==0.0.1python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install cloud-runtimes-python==0.0.1from cloud_runtimes import CloudRuntimesClient
# Initialize client
client = CloudRuntimesClient(
endpoint="http://localhost:3500",
timeout=30.0
)
# Use the RPC service
response = client.rpc.invoke_method(
service="service-name",
method="my-method",
data={"key": "value"}
)
# Use the State service
client.state.save(
store_name="state-store",
key="my-key",
value={"data": "value"}
)
# Retrieve state
state = client.state.get(
store_name="state-store",
key="my-key"
)import asyncio
from cloud_runtimes import CloudRuntimesClient
async def main():
client = CloudRuntimesClient()
# Async method invocation
response = await client.rpc.invoke_method_async(
service="service-name",
method="my-method",
data={"key": "value"}
)
# Async state operations
await client.state.save_async(
store_name="state-store",
key="my-key",
value={"data": "value"}
)
asyncio.run(main())Choose your runtime implementation:
# For Capa SDK
pip install capa-python
# For Dapr
pip install dapr
# For Layotto (coming soon)
pip install cloud-runtimes-layottofrom typing import Any, Dict
from cloud_runtimes.rpc import RpcService
class RpcService:
def invoke_method(
self,
service: str,
method: str,
data: Dict[str, Any]
) -> Dict[str, Any]:
"""Invoke a method on a remote service."""
...
async def invoke_method_async(
self,
service: str,
method: str,
data: Dict[str, Any]
) -> Dict[str, Any]:
"""Async method invocation."""
...from typing import List, Dict
from cloud_runtimes.configuration import ConfigurationService
class ConfigurationService:
def get_configuration(
self,
store_name: str,
keys: List[str]
) -> Dict[str, str]:
"""Get configuration values."""
...
def subscribe_configuration(
self,
store_name: str,
keys: List[str]
) -> "ConfigurationSubscription":
"""Subscribe to configuration changes."""
...from typing import Any, Optional
from cloud_runtimes.state import StateService, StateItem
class StateService:
def get(
self,
store_name: str,
key: str
) -> Optional[Any]:
"""Get a state value."""
...
def save(
self,
store_name: str,
key: str,
value: Any,
metadata: Optional[dict] = None
) -> None:
"""Save a state value."""
...
def delete(
self,
store_name: str,
key: str
) -> None:
"""Delete a state value."""
...Cloud Runtimes Python is part of the broader Capa Cloud ecosystem:
| Project | Language | Description |
|---|---|---|
| cloud-runtimes-jvm | Java | JVM API specification |
| cloud-runtimes-golang | Go | Go API specification |
| capa-python | Python | Python SDK implementation |
We welcome contributions from the Python community!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Clone the repository
git clone https://github.com/capa-cloud/cloud-runtimes-python.git
cd cloud-runtimes-python
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest tests/
# Run code quality checks
black .
isort .
flake8We use industry-standard tools for code quality:
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Building portable, vendor-neutral cloud APIs for Python


