fraclab-sdk 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CHANGELOG.md +50 -0
- README.md +73 -7
- fraclab_sdk/__init__.py +3 -0
- fraclab_sdk/devkit/__init__.py +8 -0
- fraclab_sdk/devkit/validate.py +836 -75
- fraclab_sdk/specs/__init__.py +22 -0
- fraclab_sdk/specs/output.py +33 -0
- fraclab_sdk/version.py +5 -0
- fraclab_sdk/workbench/Home.py +162 -0
- fraclab_sdk/workbench/__init__.py +4 -0
- fraclab_sdk/workbench/__main__.py +48 -0
- fraclab_sdk/workbench/pages/1_Snapshots.py +577 -0
- fraclab_sdk/workbench/pages/2_Browse.py +513 -0
- fraclab_sdk/workbench/pages/3_Selection.py +464 -0
- fraclab_sdk/workbench/pages/4_Run.py +331 -0
- fraclab_sdk/workbench/pages/5_Results.py +298 -0
- fraclab_sdk/workbench/pages/6_Algorithm_Edit.py +116 -0
- fraclab_sdk/workbench/pages/7_Schema_Edit.py +160 -0
- fraclab_sdk/workbench/pages/8_Output_Edit.py +155 -0
- fraclab_sdk/workbench/pages/9_Export_Algorithm.py +386 -0
- fraclab_sdk/workbench/pages/__init__.py +1 -0
- fraclab_sdk/workbench/ui_styles.py +103 -0
- fraclab_sdk/workbench/utils.py +43 -0
- {fraclab_sdk-0.1.0.dist-info → fraclab_sdk-0.1.2.dist-info}/METADATA +77 -8
- {fraclab_sdk-0.1.0.dist-info → fraclab_sdk-0.1.2.dist-info}/RECORD +27 -8
- {fraclab_sdk-0.1.0.dist-info → fraclab_sdk-0.1.2.dist-info}/entry_points.txt +1 -0
- {fraclab_sdk-0.1.0.dist-info → fraclab_sdk-0.1.2.dist-info}/WHEEL +0 -0
CHANGELOG.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Validation System Upgrade
|
|
6
|
+
- **InputSpec strict validation**:
|
|
7
|
+
- `json_schema_extra` whitelist enforcement (unknown keys → ERROR, `x_*` prefix → WARNING for extensions)
|
|
8
|
+
- `show_when` canonical operators only: `equals`, `not_equals`, `gt`, `gte`, `lt`, `lte`, `in`, `not_in`
|
|
9
|
+
- Operator aliases (`eq`, `neq`, `nin`) emit WARNING and normalize to canonical form
|
|
10
|
+
- snake_case field path detection with camelCase fix suggestions (UI compatibility)
|
|
11
|
+
- JSON Schema path resolution with `$ref`, `allOf`, `anyOf/oneOf` handling (Pydantic v2 patterns)
|
|
12
|
+
- `enum_labels` must match enum values exactly (missing/extra keys → ERROR)
|
|
13
|
+
- Leaf fields missing `title` emit WARNING
|
|
14
|
+
- **OutputContract policy checks**:
|
|
15
|
+
- Schema structure validation per kind (`frame`, `object`, `blob`, `scalar`)
|
|
16
|
+
- `dimensions` cannot overlap with owner-level keys (`stageId`, `wellId`, `platformId`)
|
|
17
|
+
- `groupPath` depth limit warning (max 4 levels)
|
|
18
|
+
- Invariants validation: dataset references must exist, `sameOwner` level must match
|
|
19
|
+
- Relations validation: dataset/field references must exist, blob/scalar cannot have field relations
|
|
20
|
+
- **Algorithm signature validation**:
|
|
21
|
+
- `main.py` must exist with top-level `run` function
|
|
22
|
+
- `async def run` not supported (sandbox limitation)
|
|
23
|
+
- Exactly 1 positional parameter required (no `*args`, `**kwargs`, keyword-only args)
|
|
24
|
+
- **Export page integration**:
|
|
25
|
+
- Cached validation with mtime-based invalidation (avoids re-running on every rerender)
|
|
26
|
+
- Status badges for InputSpec, OutputContract, Algorithm
|
|
27
|
+
- Validation details expander with fix suggestions for snake_case issues
|
|
28
|
+
- Export blocked when validation errors exist
|
|
29
|
+
|
|
30
|
+
### Other Changes
|
|
31
|
+
- Export page: Replace "File Status" with "Validation Status" as the primary integrity check; File Inspector in expander (expanded by default); Revalidate button inline with status badges.
|
|
32
|
+
- Schema/Output Edit pages: Show warnings even when validation passes; fix incorrect path passed to `validate_output_contract`.
|
|
33
|
+
- Single .py file import: Now creates full template structure (`schema/`, `dist/`) matching "Create New Algorithm".
|
|
34
|
+
- Algorithm scaffold: Now creates `dist/output_contract.json` template.
|
|
35
|
+
- Flatten exported algorithm zip structure (no top-level version folder in Workbench export).
|
|
36
|
+
- Manifest defaults: add `requires.sdk`, `repository`, `homepage`, `license` to scaffolds and bundled examples.
|
|
37
|
+
- Workbench Run/Results pages prompt users to use the InputSpec/OutputSpec editor Validate actions when UI or artifacts are missing.
|
|
38
|
+
- Workbench pages default sidebar to expanded to avoid being trapped when the Streamlit toolbar is hidden.
|
|
39
|
+
- Keep Streamlit toolbar visible (deploy button hidden) so the sidebar toggle is always accessible.
|
|
40
|
+
- Force sidebar to stay visible via CSS so navigation is always reachable.
|
|
41
|
+
- Hide the sidebar collapse control to keep navigation fixed open.
|
|
42
|
+
|
|
43
|
+
## 0.1.1
|
|
44
|
+
- Package the Streamlit Workbench inside `fraclab_sdk` with the `fraclab-workbench` entrypoint; optional `workbench` extra pulls UI deps.
|
|
45
|
+
- Restore core scientific deps to the base install (numpy/pandas/scipy/matplotlib/fastapi/rich) while keeping Workbench UI deps optional.
|
|
46
|
+
- Add manifest defaults for `requires.sdk`, `repository`, `homepage`, `license`, and embed the SDK version constant for templating.
|
|
47
|
+
- Update bundled example manifests to include the new metadata fields.
|
|
48
|
+
|
|
49
|
+
## 0.1.0
|
|
50
|
+
- Initial public SDK release with snapshots, algorithm library, run manager, CLI, and devkit tooling.
|
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Fraclab SDK Reference
|
|
2
2
|
|
|
3
|
-
> 版本: 0.1.
|
|
3
|
+
> 版本: 0.1.1
|
|
4
4
|
> Python: >=3.11
|
|
5
5
|
|
|
6
6
|
Fraclab SDK 是一个算法开发与执行框架,帮助算法开发者快速构建、测试和部署数据处理算法。
|
|
@@ -23,12 +23,26 @@ Fraclab SDK 是一个算法开发与执行框架,帮助算法开发者快速
|
|
|
23
23
|
|
|
24
24
|
## 安装
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
轻量安装(核心 SDK / CLI,自动带上科学计算依赖):
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
pip install
|
|
29
|
+
pip install fraclab-sdk
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
安装并启用 Workbench UI:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install "fraclab-sdk[workbench]"
|
|
36
|
+
fraclab-workbench # CLI entry point
|
|
37
|
+
# 或
|
|
38
|
+
python -m fraclab_sdk.workbench
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 依赖说明
|
|
42
|
+
|
|
43
|
+
- 核心安装会自动安装并锁定:`numpy>=2.1.1`, `pandas>=2.2.3`, `scipy>=1.13.1`, `matplotlib>=3.9.2`, `fastapi>=0.115.0`, `rich>=13.9.0`。无需手动再装,避免版本冲突。
|
|
44
|
+
- 可选 `workbench` 额外安装 UI 依赖:`streamlit>=1.30`, `pyarrow>=16.0.0`(`pandas` 已在核心里)。
|
|
45
|
+
|
|
32
46
|
---
|
|
33
47
|
|
|
34
48
|
## 快速开始:编写你的第一个算法
|
|
@@ -46,13 +60,63 @@ from fraclab_sdk.runtime import DataClient, ArtifactWriter
|
|
|
46
60
|
|
|
47
61
|
### 2. 编写算法入口
|
|
48
62
|
|
|
49
|
-
创建 `main.py`
|
|
63
|
+
创建 `main.py` 作为算法入口文件。
|
|
64
|
+
|
|
65
|
+
#### 入口函数签名约定
|
|
66
|
+
|
|
67
|
+
**算法入口函数必须严格遵循以下签名:**
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
def run(ctx):
|
|
71
|
+
...
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
| 约定 | 要求 | 说明 |
|
|
75
|
+
|------|------|------|
|
|
76
|
+
| 文件名 | `main.py` | 必须是 `main.py`,不能是其他名称 |
|
|
77
|
+
| 函数名 | `run` | 必须是 `run`,区分大小写 |
|
|
78
|
+
| 参数 | 仅 `ctx` 一个参数 | SDK 使用 `module.run(ctx)` 调用,**不支持**其他签名 |
|
|
79
|
+
| 返回值 | 无要求 | 返回值会被忽略 |
|
|
80
|
+
|
|
81
|
+
> **警告**: 以下写法都会导致运行失败:
|
|
82
|
+
> ```python
|
|
83
|
+
> # ❌ 错误: 参数名不影响,但参数个数必须是 1
|
|
84
|
+
> def run(ctx, extra_arg): # TypeError: run() missing required argument
|
|
85
|
+
>
|
|
86
|
+
> # ❌ 错误: 函数名错误
|
|
87
|
+
> def execute(ctx): # AttributeError: module has no attribute 'run'
|
|
88
|
+
>
|
|
89
|
+
> # ❌ 错误: 放在其他文件
|
|
90
|
+
> # algorithm.py 中定义 run() # 不会被加载
|
|
91
|
+
> ```
|
|
92
|
+
|
|
93
|
+
#### 最小可运行模板
|
|
50
94
|
|
|
51
95
|
```python
|
|
52
96
|
# main.py
|
|
53
|
-
|
|
54
|
-
|
|
97
|
+
def run(ctx):
|
|
98
|
+
"""算法入口函数 - 最小模板。
|
|
55
99
|
|
|
100
|
+
Args:
|
|
101
|
+
ctx: RunContext,包含:
|
|
102
|
+
- ctx.data_client: DataClient 实例
|
|
103
|
+
- ctx.params: dict[str, Any],用户参数
|
|
104
|
+
- ctx.artifacts: ArtifactWriter 实例
|
|
105
|
+
- ctx.logger: logging.Logger 实例
|
|
106
|
+
- ctx.run_context: dict,运行上下文
|
|
107
|
+
"""
|
|
108
|
+
logger = ctx.logger
|
|
109
|
+
logger.info("算法开始执行")
|
|
110
|
+
|
|
111
|
+
# 你的逻辑...
|
|
112
|
+
|
|
113
|
+
logger.info("算法执行完成")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### 完整示例
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
# main.py
|
|
56
120
|
def run(ctx):
|
|
57
121
|
"""算法入口函数。
|
|
58
122
|
|
|
@@ -313,7 +377,7 @@ aw.write_scalar(
|
|
|
313
377
|
"drsPath": "dist/drs.json"
|
|
314
378
|
},
|
|
315
379
|
"requires": {
|
|
316
|
-
"sdk": "0.1.
|
|
380
|
+
"sdk": "0.1.1",
|
|
317
381
|
"core": "1.0.0"
|
|
318
382
|
},
|
|
319
383
|
"repository": "https://github.com/example/my-algorithm",
|
|
@@ -826,6 +890,8 @@ $ fraclab-sdk run tail f9e8d7c6
|
|
|
826
890
|
$ fraclab-sdk run tail f9e8d7c6 --stderr
|
|
827
891
|
```
|
|
828
892
|
|
|
893
|
+
> Workbench 提示:结果页面会展示本次运行的输出目录路径(含 `_logs` 日志),即使运行失败也能点开路径定位调试。
|
|
894
|
+
|
|
829
895
|
#### 6. 运行目录结构
|
|
830
896
|
|
|
831
897
|
执行完成后,`~/.fraclab/runs/<run_id>/` 目录结构:
|
fraclab_sdk/__init__.py
CHANGED
|
@@ -7,6 +7,7 @@ from fraclab_sdk.results import ResultReader
|
|
|
7
7
|
from fraclab_sdk.run import RunManager, RunMeta, RunResult, RunStatus
|
|
8
8
|
from fraclab_sdk.selection.model import SelectionModel
|
|
9
9
|
from fraclab_sdk.snapshot import SnapshotHandle, SnapshotLibrary, SnapshotMeta
|
|
10
|
+
from fraclab_sdk.version import __version__
|
|
10
11
|
|
|
11
12
|
__all__ = [
|
|
12
13
|
# Config
|
|
@@ -31,4 +32,6 @@ __all__ = [
|
|
|
31
32
|
"RunStatus",
|
|
32
33
|
# Results
|
|
33
34
|
"ResultReader",
|
|
35
|
+
# Package metadata
|
|
36
|
+
"__version__",
|
|
34
37
|
]
|
fraclab_sdk/devkit/__init__.py
CHANGED
|
@@ -9,6 +9,10 @@ This module provides tools for:
|
|
|
9
9
|
from fraclab_sdk.devkit.compile import compile_algorithm
|
|
10
10
|
from fraclab_sdk.devkit.export import export_algorithm_package
|
|
11
11
|
from fraclab_sdk.devkit.validate import (
|
|
12
|
+
ValidationIssue,
|
|
13
|
+
ValidationResult,
|
|
14
|
+
ValidationSeverity,
|
|
15
|
+
validate_algorithm_signature,
|
|
12
16
|
validate_bundle,
|
|
13
17
|
validate_inputspec,
|
|
14
18
|
validate_output_contract,
|
|
@@ -18,6 +22,10 @@ from fraclab_sdk.devkit.validate import (
|
|
|
18
22
|
__all__ = [
|
|
19
23
|
"compile_algorithm",
|
|
20
24
|
"export_algorithm_package",
|
|
25
|
+
"ValidationSeverity",
|
|
26
|
+
"ValidationIssue",
|
|
27
|
+
"ValidationResult",
|
|
28
|
+
"validate_algorithm_signature",
|
|
21
29
|
"validate_bundle",
|
|
22
30
|
"validate_inputspec",
|
|
23
31
|
"validate_output_contract",
|