Appearance
Level 1 run_benchmark 总顺序
Abstract
入口:
pythonif __name__ == "__main__":这一层只解释一件事:
run_benchmark.py在最高层顺序上怎样把命令行运行,变成一次完整 benchmark。
1. 上一层与当前层位置
上一层是:
当前层是:
- Level 1:只看
run_benchmark.py自己的顺序,不下钻pipeline(...)内部。
当前层对应上一层中的具体位置是:
- 20-代码梳理-BFS方法与当前主线 里的
Level 1 run_benchmark 总顺序
2. 当前层第一性
run_benchmark.py 的第一性是:
把“命令行参数 + JSON 配置文件”变成“可执行 benchmark 配置”,再把
pipeline(...)产生的日志文件交给report(...)。
这意味着它的职责不是:
- 读 CSV 细节
- 训练模型
- 做 rolling 预测
而是:
- 解析输入
- 组装配置
- 调用主执行入口
pipeline(...) - 调用结果展示入口
report(...)
3. 当前命令的最小例子
这一层以下文这条命令作为具体例子:
text
python scripts/run_benchmark.py
--config-path rolling_forecast_config.json
--data-name-list ETTh1.csv
--model-name time_series_library.DLinear
--adapter transformer_adapter
--model-hyper-params {"batch_size":4,"d_model":32,"d_ff":128,"moving_avg":25,"dropout":0.0,"lr":0.0001,"num_epochs":1,"num_workers":0,"seq_len":96,"horizon":24}
--strategy-args {"horizon":24,"tv_ratio":0.8,"train_ratio_in_tv":0.75,"stride":24,"num_rollings":48}
--num-workers 1
--timeout 600
--save-path debug\\ETTh1_DLinear_rolling_min_allmetrics4. Level 1 顺序图
5. 抽象索引树
这棵树不是执行顺序图,而是:
为了让人脑快速索引
run_benchmark.py的四个逻辑分块。
6. 职责树
6.1 输入解析
负责生成:
argsconfig_data
6.2 配置组装
负责生成:
data_configmodel_configevaluation_configreport_config
6.3 执行 benchmark
负责调用:
pipeline(data_config, model_config, evaluation_config)
返回:
log_filenames
6.4 结果展示
负责调用:
report(report_config, report_method=args.report_method)
7. 输入输出接口
7.1 关键输入
args- 来自
argparse
- 来自
config_data- 来自
json.load(...)
- 来自
7.2 关键中间变量
data_configmodel_configevaluation_configreport_config
7.3 关键输出
log_filenames- 类型:
List[str] - 语义:本次 benchmark 产出的日志文件路径列表
- 类型:
8. 函数 / 文件关系图
9. 这一层对当前例子的具体落地
在这条命令下,run_benchmark.py 这一层真正做的是:
- 读取
rolling_forecast_config.json - 用命令行覆盖默认值
- 得到:
data_config里有ETTh1.csvmodel_config里有time_series_library.DLinearevaluation_config里有rolling_forecast和horizon=24
- 调
pipeline(...) - 拿到日志文件列表
- 再把这些日志交给
report(...)
10. 下一层入口
下一层要 BFS 细分的是:
python
pipeline(
data_config,
model_config,
evaluation_config,
)对应:
11. 只留一句
Level 1 只看
run_benchmark.py怎样把“命令行运行”变成“pipeline(...)+report(...)”。