Scalim: a Python-first compute runtime (IR / planning / execution / sinks / observability).
Project description
Scalim
用纯 Python 构建的声明式数据流水线运行时 — DSL 不可知,自适应并发,生产级可观测性
核心特性
声明式 IR(中间表示)
用 Python 对象描述复杂的数据需求,而非命令式代码:
DemandIr(
source=SourceIr(name=”orders”, loader=load_orders),
fields=[
FieldIr(name=”order_id”, source_field=”order_id”),
FieldIr(name=”total_amount”, source_field=”amount”,
derive=lambda x: sum(x)),
],
relations=[
RelationIr(
name=”payment”,
source_key=”pay_id”,
target=SourceIr(name=”payments”, loader=load_payments),
target_key=”id”,
bindings=[
BindingIr(field=”method”, target_field=”payment_method”)
]
)
]
)
支持多级关联链(orders → payments → countries)、复合键、派生字段与自动循环依赖检测。
自适应并发执行
ScalimEngine 的 adaptive 模式会自动分析数据依赖图,智能决策并发策略:
- 自动识别并发机会:基于依赖图的拓扑分析
- Fan-out/Fan-in 编排:独立任务并行执行,依赖任务串行化
- 资源感知调度:根据任务数量、数据量、CPU 资源动态调整
- 快速失败回退:并发失败自动降级到串行模式
无需手动优化 — 运行时自动为你找到最优执行路径。
生产级可观测性
16+ 种事件类型 + 4 种预设 Observer:
- PerformanceObserver:吞吐量、延迟统计
- MemoryOptimizationObserver:内存释放追踪
- RelationObserver:关系查找命中率
- ExecutionTraceObserver:完整执行链路追踪
observer = PerformanceObserver(config=PerformanceConfig(
enable_loader_timing=True,
enable_field_compute_timing=True
))
engine = ScalimEngine(observers=[observer])
运行时防护机制
内置 Guardrails 系统,提供策略模式错误处理(quiet / fast_fail),可自定义 Loader 级别的错误策略,实现细粒度容错控制。
快速开始
pip install scalim
just notebook # 交互式教程
质量保证
- 100% 测试覆盖率(668 个测试用例)
- 基于 pyright 的严格类型检查(0 errors, 0 warnings)
- Ruff 全量规则通过
- Python 3.10+ 全版本支持
设计哲学
- Core First:核心运行时与方言/CLI 解耦
- Type Safety:完整的类型注解,支持静态分析
- Observable:默认可观测,而非事后补丁
- Extensible:通过 Hook/Observer/Policy 三大扩展点支持自定义
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 scalim-0.1.0.tar.gz.
File metadata
- Download URL: scalim-0.1.0.tar.gz
- Upload date:
- Size: 131.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea950506cc27ed255951ebffcc9da2b0f7250db6c0d85bc58a331e65a2bc5811
|
|
| MD5 |
b3c709df1151c6ce896b4119611adca3
|
|
| BLAKE2b-256 |
9fbf5104e4b866e6998859d7c045d6276c841288510be8266eb97cedbdf09900
|
File details
Details for the file scalim-0.1.0-py3-none-any.whl.
File metadata
- Download URL: scalim-0.1.0-py3-none-any.whl
- Upload date:
- Size: 190.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ca9048938c72d4ef96dc173ff3c14749a08a17a014060507c2d04b720f3e277
|
|
| MD5 |
e085f82ec946a78b290737b2ce134edb
|
|
| BLAKE2b-256 |
ad1d04e68ab853ac66a66bfd7e0a86a27e58ff888175000eb384784f106d4e59
|