Files
DCTS/tools/import_results
fmq d16b3d3cdc feat(all): 数据库模块化拆分与版本化迁移、任务引擎命名体系收敛、物理输出校验加固与用户配置接通
- server/db: 拆 4929 行 db.rs 单体为 db/ 目录,migrations.rs 引入 PRAGMA user_version
    版本化迁移运行器(M1~M13)
  - 任务引擎 Phase 6/7b/7c 改名收敛:EngineStageConfig→PhaseConfig、StagePolicy→ResumePolicy、
    Converged→Completed、删除 task_type 列、success_method 拆 tlusty_/synspec_ 双列、
    新增 tlusty_status/synspec_status 半失败阶段守卫
  - 科学正确性加固:conv_check 任意行 NaN/Inf/溢出判无效(0 行容忍)、新增 spec_is_valid
    校验 SYNSPEC 脏谱、itek_history 逐次迭代全量保真、fmt_abn powf 溢出饱和
  - 用户配置真正接通:tlusty_chain/tlusty_input 由死字段经 调度器→TaskSpec→executor→runner
    透传生效;config 加载期 validate + deny_unknown_fields + 解析失败记 warn
  - 调度修复:H1 活锁(pending_strategies 跳过已失败策略)、种子查找错误不再静默降级冷启动
  - dashboard: 阶段配置面板 tlusty_stage/synspec_stage、"已完成"标签、迭代诊断展示
  - docs: 新增 database_refactor_design.md,同步 database/api/PIPELINE/workflow_detail
2026-08-06 20:51:21 +08:00
..

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/datanode 的 DCTS_RESULT_DIR=/app/data/result,故工具在服务器宿主机 运行即可被 node 识别为已有结果归档。

命名以 workflow 配置为准GridConfig::from_yaml_str 保留 YAML 源小数精度(如 logg: 5.0g5.0),而非旧 conv.json 里的 name。


🚀 编译

cargo build -p import_results --release

使用示例

# 完整导入(产物树 + 入库)
./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 之后启动工作流 BB 看不到 A 的 converged 标记,会重算全部已算过的点

正确顺序:

# 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 原文完整保留。