Expand description
Modern Python Plugin Runtime
AI-era design for running Python plugins in SochDB using:
- Pyodide: Full CPython 3.12 with numpy, pandas, scikit-learn
- WASM Component Model: Standard interfaces for cross-language composition
- AI Triggers: Natural language → Python code generation
§Architecture
┌──────────────────────────────────────────────────────────┐
│ Python Plugin System │
├──────────────────────────────────────────────────────────┤
│ PythonPlugin → PyodideRuntime → WASM Sandbox │
│ ↓ ↓ ↓ │
│ packages: micropip Memory isolation │
│ numpy,pandas install Resource metering │
└──────────────────────────────────────────────────────────┘§Example
ⓘ
let runtime = PyodideRuntime::new(RuntimeConfig::default()).await?;
runtime.install_packages(&["numpy", "pandas"]).await?;
let plugin = PythonPlugin::new("fraud_detector")
.with_code(r#"
import numpy as np
def on_insert(row):
if row["amount"] > 10000:
raise TriggerAbort("Amount too high")
return row
"#)
.with_trigger("transactions", TriggerEvent::BeforeInsert);
runtime.register(plugin)?;Structs§
- AiTrigger
Generator - Generates Python trigger code from natural language instructions
- Pyodide
Runtime - Pyodide-based Python runtime
- Python
Plugin - A Python plugin with code and trigger bindings
- Runtime
Config - Configuration for the Pyodide runtime
- Runtime
Stats - Runtime statistics
- Trigger
Context - Context passed to trigger execution
Enums§
- Trigger
Event - Types of trigger events
- Trigger
Result - Result from trigger execution