Skip to content

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

Merged
TATP-233 merged 1 commit into
dev/issue-1042-manager-based-apifrom
refactor/issue-1240-device-info-library
Aug 21, 2026
Merged

refactor: 掐断库层对 scripts/ 的反向依赖(device_info 提升入库)#1245
TATP-233 merged 1 commit into
dev/issue-1042-manager-based-apifrom
refactor/issue-1240-device-info-library

Conversation

@TATP-233

Copy link
Copy Markdown
Collaborator

Fixes #1240
Part of #1239

改动

  • src/unilab/utils/device.py:迁入 device 信息采集实现(macOS/Linux/Windows 采集器 + get_device_info_dict / get_device_info_line),采集字段与格式逐字段保持不变。
  • src/unilab/training/experiment.py:删除 _benchmark_device_info_path 目录遍历 + exec_module 动态加载 + fallback,改为正常 from unilab.utils.device import get_device_info_dict
  • scripts/benchmark/core/device_info.py:295 行实现缩减为薄壳 re-export,benchmark 框架其余部分不动。
  • 测试:linux 采集两条测试从 tests/benchmark/ 移至 tests/utils/test_device.py;实验追踪测试改为断言直接使用库层 helper;新增 tests/test_library_import_boundary.py(AST 扫描断言 src/unilab 内任何模块不 import scripts.*)。

范围说明

src/unilab/cli.pydemo.pyipc/dp_launcher.py 仍有按路径定位 scripts/ 的引用,属于 CLI 执行路径设计,不在 #1240 范围内,未触碰。

Validation

  • make test-all 已完成并通过(ruff format/check、mypy、pyright、全量 pytest 带 coverage、benchmark smoke 32/33 + 33/34,1 个 mlx 平台可选项跳过)。
  • 仓库外(/tmp)import unilab.training.experiment 成功,sys.modules 中无任何 scripts.* 模块。
  • benchmark 薄壳 re-export 与库层函数为同一对象,get_device_info_line() 输出格式不变。

@TATP-233
TATP-233 merged commit 697f45a into dev/issue-1042-manager-based-api Aug 21, 2026
4 of 6 checks passed
@TATP-233
TATP-233 deleted the refactor/issue-1240-device-info-library branch August 21, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant