Skip to content

refactor: 掐断库层对 scripts/ 的反向依赖(device_info 提升入库) #1240

Description

@TATP-233

Part of #1239

问题

src/unilab/training/experiment.py:73-97 在运行时向上遍历目录,定位 scripts/benchmark/core/device_info.pyexec_module 执行。这是依赖方向倒置:库层代码依赖不在发行包内的 scripts/ 文件,安装方式或工作目录一变就断。

做什么

  • 把 device 信息采集能力提升到库层:与 src/unilab/training/monitoring.pyHardwareMonitor 合并,或收进 src/unilab/utils/device.py(二选一,以实现时更小 diff 为准)。
  • training/experiment.py 改为正常 import,删除 exec_module 路径。
  • scripts/benchmark/core/device_info.py 变为薄壳 re-export 或删除(benchmark 框架其余部分不动)。

不做什么

  • 不改 benchmark 框架的其他部分;
  • 不改采集的指标内容与字段名(run_config.json / run_summary.json 里的硬件元数据格式保持逐字段一致)。

预计规模

约 5 个文件,净 +150/-200 行。

验收

  • pip install 后的包在仓库外任意目录 import unilab.training.experiment 成功,不依赖 scripts/ 存在;
  • 新增一条测试:断言 src/unilab/ 内任何模块不 import scripts/ 路径;
  • make test-all 通过。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions