核心变更:
1. GridAxisValue 源精度命名
- 新增 GridAxisValue 类型,携带 f64 数值 + YAML 源书写文本(Deref 透明兼容算术)
- config.rs 绕过 serde_yaml 归一化,逐 token 捕获轴值原文(logg: 5.0 → g5.0)
- runner/executor/scheduler 全链路改用 DB TEXT 列权威 point_name,
修复 REAL 列回读丢精度导致的 model_name 错配
2. 工作流执行可观测台
- 新增 stats/progress/points 三组 API(进度时间序列、经验速率 ETA、
停滞预警、逐点明细分页、收敛性热力图数据)
- 新增 workflow_progress_snapshots 表 + tasks/grid_points 耗时列
- runner 携带 last_iter/worst_depth/n_depths 进 conv.json
- 前端新增 hash 路由、工作流详情页(概览/网格点/收敛分析三 Tab)、YAML 编辑器
3. 节点停用/启用管理
- 新增 disabled 状态 + disable/enable API;停用节点保持心跳但停止分发,
worker 空闲待命而非退出;移除 revoke API,token 失效统一走重发覆盖;
移除 host_name 字段
4. 白名单结果归档
- 新增 result_filter 模块,只归档有语义产物,丢弃 Tlusty 中间单元(~2MB/模型)
- executor 原子写入归档 + 200 点 LRU 上限
5. 历史数据导入
- sync_seeds 重写为 import_results:经 /admin/import_seed 标记 converged +
按新版命名迁移产物树
6. 部署与目录重规划
- data/results→seeds、data/archive→result + migrate_data_dirs.sh
- deploy.sh 增强(SSH 复用、Profile、远程 env);Dockerfile 瘦身
7. 文档同步更新 api/database/architecture/deployment
110 lines
4.8 KiB
Markdown
110 lines
4.8 KiB
Markdown
# import_results
|
||
|
||
> DCTS 历史计算结果导入工具。把旧版 Python 单机 `run_grid.py`/`run_one.py` 的计算结果
|
||
> 完整迁移到当前分布式系统,**避免重算已完成的网格点**。
|
||
|
||
---
|
||
|
||
## 📦 模块概览
|
||
|
||
`import_results` 承担**双职责**:
|
||
|
||
1. **入库 + 种子库**:经服务端 `/api/admin/import_seed` 把旧版的收敛结果(`conv.json` + `.7`
|
||
大气文件)上传,把 `grid_points` 标记为 `converged`。这样启动工作流时这些点会被跳过,
|
||
不再重复计算。
|
||
2. **完整产物树迁移**:把旧目录的全部产物文件,按**新版 node result 格式 + workflow 配置
|
||
的小数精度命名**,拷贝到本地 `data/result/<name>/`。docker-compose 里 server/node 都挂载
|
||
`./data:/app/data`,node 的 `DCTS_RESULT_DIR=/app/data/result`,故工具在服务器宿主机
|
||
运行即可被 node 识别为已有结果归档。
|
||
|
||
**命名以 workflow 配置为准**:`GridConfig::from_yaml_str` 保留 YAML 源小数精度(如
|
||
`logg: 5.0` → `g5.0`),而非旧 `conv.json` 里的 name。
|
||
|
||
---
|
||
|
||
## 🚀 编译
|
||
|
||
```bash
|
||
cargo build -p import_results --release
|
||
```
|
||
|
||
## 使用示例
|
||
|
||
```bash
|
||
# 完整导入(产物树 + 入库)
|
||
./target/release/import_results \
|
||
--dir /旧数据/results \
|
||
--config workflows/sdB_cno.yaml \
|
||
--result-dir data/result \
|
||
--server http://127.0.0.1:8090 \
|
||
--workflow sdB_cno \
|
||
--token <admin_token>
|
||
```
|
||
|
||
### 参数说明
|
||
|
||
| 参数 | 说明 |
|
||
|---|---|
|
||
| `-d/--dir <dir>` | 旧版 `run_grid.py` 的 results 根目录(默认 `data/results`) |
|
||
| `-c/--config <yaml>` | **必填**。workflow 配置,用于推导权威命名 + 校验网格点 |
|
||
| `-r/--result-dir <dir>` | 产物树写入目标(默认 `data/result`,与 node 的 DCTS_RESULT_DIR 同卷)。旧长名 `--archive-dir` 仍兼容(仅长选项) |
|
||
| `-s/--server <url>` | 服务端 API 地址(默认 `http://127.0.0.1:8090`) |
|
||
| `-w/--workflow <name>` | **必填**。目标工作流名,**必须等于将来要启动的工作流名** |
|
||
| `-t/--token <token>` | 服务端 Admin 鉴权令牌 |
|
||
|
||
---
|
||
|
||
## ⚠️ 关键注意事项
|
||
|
||
### 1. `-w` 工作流名必须匹配将来要启动的工作流
|
||
|
||
`grid_points` 唯一键是复合 `(workflow_name, name)`,工作流强隔离。若导入到工作流 `A`,
|
||
之后启动工作流 `B`,`B` 看不到 `A` 的 converged 标记,会**重算全部已算过的点**。
|
||
|
||
正确顺序:
|
||
```bash
|
||
# 1. 先导入(-w = 目标工作流名)
|
||
./import_results -d /旧数据/results -c workflows/sdB_cno.yaml -w sdB_cno ...
|
||
|
||
# 2. 在 Dashboard 用同名配置创建工作流 sdB_cno
|
||
# 3. 启动 sdB_cno
|
||
# → initialize_grid 对已导入点 DO NOTHING(保留 converged,跳过重算)
|
||
# → 对配置里有但旧数据没有的新点,插入 pending(正常计算)
|
||
```
|
||
|
||
### 2. 文件名映射规则(旧 → 新 result 格式)
|
||
|
||
| 旧文件 | 新文件 |
|
||
|---|---|
|
||
| `conv.json` | `conv.json` |
|
||
| `<old>.7/.spec/.cont/.iden/.log` | `<new>.7/.spec/.cont/.iden/.log` |
|
||
| `<old>.lte.7/.nc.7/.nl.7` | `<new>.lte.7/.nc.7/.nl.7` |
|
||
| `<old>.nc_chmax0p001_itekNone.9` | `<new>.nc_chmax0.001.9` |
|
||
| `<old>.5/.6`(旧版只留最后阶段) | `<new>.nl.5/.nl.6` |
|
||
| `fort.8` | `fort.8` |
|
||
|
||
**跳过**:迁移后的文件名统一经结果白名单(`common::result_filter::is_result_worthy`,
|
||
与 node 实时结果归档共用同一份判别规则)复核。不在白名单内的一律跳过,包括:
|
||
- 软链(`data`/`fort.19`)
|
||
- `fort.84`、`*.tmp`
|
||
- 新版已清理的裸文件(`nst`/`fort.9`/`fort.12`/`fort.17`,内容已被 `.iden/.cont/_chmax.9` 覆盖)
|
||
- Tlusty 中间工作单元(`fort.1/2/3/13/14/18/22/42/44/50/57/69/82/95` 等,无语义价值)
|
||
- 无 `_chmax` 的 `.9` 阶段快照(与 `<name>.<label>_chmax*.9` 内容重复,唯一保留 `_chmax.9`)
|
||
|
||
旧版因「每阶段覆盖」丢失的中间阶段 `.5/.6/.err/.nst`(只留最后 nl 阶段)无法重建,
|
||
归到 `.nl.` 标签下。
|
||
|
||
### 3. 导入数据的字段去向
|
||
|
||
| 旧 conv.json 字段 | 落库位置 | 展示 |
|
||
|---|---|---|
|
||
| `name`(被工具重写为配置权威名) | `grid_points.name` | 点表/详情 |
|
||
| `converged && !atmosphere_has_nan` | `grid_points.status='converged'` | 状态徽章 |
|
||
| —(固定值) | `grid_points.success_method='imported'` | 方法徽章"导入" |
|
||
| `final_max_relc` | 种子库记录 + conv.json 原文 | 点详情 |
|
||
| `elapsed_sec` | `grid_points.last_elapsed_sec` | 点表"耗时"列 |
|
||
| 全文(含 `stages[].itek_attempts/final` 嵌套诊断) | `seeds_dir/<name>/conv.json` 原文 | 点详情阶段链(扁平字段兼容解析,嵌套诊断原文保留不丢失) |
|
||
|
||
旧版 stage 的迭代诊断(`last_iter` 等)嵌在 `final`/`itek_attempts` 里而非扁平字段,
|
||
详情页阶段链不显示迭代数,但原始数据随 conv.json 原文完整保留。
|