feat(factor): 进度页心跳判活+因子列表默认折叠(用户08-30反馈两项) [vps]
CI/CD / test (push) Successful in 4s
CI/CD / nas-deploy (push) Successful in 11s
CI/CD / nas-verify (push) Successful in 7s

痛点:因子分析分钟级运行,进度条停着看不出进行中还是死掉;240因子罗列乱。
①跨进程心跳链路:analyzer._report_progress 写 {output_dir}/{tid}.progress
(stage/detail/ts;IO故障静默——锦上添花不能伤主流程),埋点=行情加载i/N逐只
+因子特征+逐因子i/M+tears✓+完成;runner._factor_worker 透传 task_id
(默认空串兼容旧调用);GET /task/{id} 合并 _read_factor_progress(factor_
前缀才读,age=距上次活动秒数)。
②Progress.vue终端风重构:心跳区=呼吸灯(绿≤30s/琥珀≤180s静默期/红更久,
prefers-reduced-motion停动画)+「Xs前·detail」+运行时长秒表+步骤%大数字;
因子步骤=行情加载→因子计算→逐因子分析→完成(心跳stage驱动);回测/优化
保持原5步推导+进度条;useTask/TaskStatus 透传 progress。
③FactorPicker默认折叠:groups max-height 128px两行预览+渐隐底边+
「展开全部N个因子▾」按钮,搜索时自动展开。
+5测试(_report_progress写/静默/心跳读roundtrip/非factor/损坏JSON),323绿+build绿
This commit is contained in:
2026-08-30 10:17:19 +08:00
parent 557479b848
commit 8f4f564733
9 changed files with 315 additions and 86 deletions
+25
View File
@@ -376,3 +376,28 @@ def test_run_factor_analysis_ic_extraction_fails_gracefully(tmp_path):
assert "error" in report.ic_summary["ma5"]["ic"]
# Status and report should still be present
assert "status" in report.ic_summary["ma5"]
# —— 跨进程进度心跳(2026-08-30:progress 页判活) ——
def test_report_progress_writes_file(tmp_path):
"""task_id 空=不写;正常写 JSON(stage/detail/ts)."""
import json
from sanguo_factor.analyzer import _report_progress
_report_progress("", str(tmp_path), "data", "不应写入")
assert not (tmp_path / ".progress").exists()
_report_progress("factor_ab12", str(tmp_path), "analyze", "因子 2/5: kmid")
d = json.loads((tmp_path / "factor_ab12.progress").read_text(encoding="utf-8"))
assert d["stage"] == "analyze"
assert d["detail"] == "因子 2/5: kmid"
assert d["ts"] > 0
def test_report_progress_never_raises(tmp_path, monkeypatch):
"""进度是锦上添花:IO 故障必须静默(不影响分析主流程)."""
from sanguo_factor.analyzer import _report_progress
monkeypatch.setattr("builtins.open", lambda *a, **k: (_ for _ in ()).throw(OSError("boom")))
_report_progress("factor_x", str(tmp_path), "data", "x") # 不抛即过