Skip to content

refactor: reorganize directory structure#1

Open
newtontech wants to merge 2 commits into
masterfrom
fix/issue-934
Open

refactor: reorganize directory structure#1
newtontech wants to merge 2 commits into
masterfrom
fix/issue-934

Conversation

@newtontech
Copy link
Copy Markdown
Owner

This PR reorganizes the directory structure by moving all format directories into a formats/ subdirectory.

Changes

  • Created dpdata/formats/ directory
  • Moved all format directories to dpdata/formats/:
    • abacus, amber, cp2k, deepmd, dftbplus, fhi_aims
    • gaussian, gromacs, lammps, lmdb, md, openmx
    • orca, psi4, pwmat, pymatgen, qe, rdkit
    • siesta, vasp, xyz
  • Updated all import statements throughout the codebase
  • Updated relative imports in format modules (from .. to from ...)
  • Updated dpdata/__init__.py to import from new locations
  • Updated tests for new import paths

Notes

  • The plugins directory remains at the root level as requested
  • All existing tests pass with the new structure

Closes deepmodeling#934

OpenClaw Bot and others added 2 commits February 28, 2026 05:10
Move all format directories (abacus, amber, cp2k, deepmd, dftbplus,
fhi_aims, gaussian, gromacs, lammps, lmdb, md, openmx, orca, psi4,
pwmat, pymatgen, qe, rdkit, siesta, vasp, xyz) into a new formats/
subdirectory.

This addresses issue deepmodeling#934.

Changes:
- Created dpdata/formats/ directory
- Moved all format directories to dpdata/formats/
- Updated all import statements throughout the codebase
- Updated relative imports in format modules (from .. to from ...)
- Updated dpdata/__init__.py to import from new locations
- Updated tests/context.py for new import paths

The plugins directory remains at the root level as requested.
@newtontech
Copy link
Copy Markdown
Owner Author

Kimi CLI Review

Generated with kimi --print from PR metadata and patch diff. Review method: purpose-first, file/diff-based, severity-ordered findings, with tests/security/compatibility/CI impact checked.

PR 审查意见

总体评价

这是一个纯粹的目录重构 PR,将所有 format 模块从 dpdata/<format>/ 移动到 dpdata/formats/<format>/,并相应更新所有导入路径。变更范围大但逻辑清晰,无功能改动。


审查发现

🔴 高风险(阻塞性问题)

未发现阻塞性问题。

🟡 中风险(需关注)

  1. 向后兼容性破坏 — 外部用户若直接 import dpdata.vaspfrom dpdata.abacus import scf,此次重构将导致 ModuleNotFoundError。虽然 dpdata/__init__.py 保留了 from .formats import lammps, md, vasp 的顶层暴露,但并非所有旧路径都被保留。例如:

    • dpdata.abacus → 已失效
    • dpdata.gaussian.log → 已失效
    • dpdata.deepmd.raw → 已失效

    建议:在 dpdata/ 根目录下添加兼容 shim 模块(deprecated wrappers),或至少在 release note 中明确标注这是 breaking change。

  2. 文档/字符串中的旧路径未更新dpdata/plugins/gaussian.py 第 92 行 docstring 引用了 :meth:dpdata.gaussian.gjf.make_gaussian_input``,虽已改为 dpdata.formats.gaussian.gjf.make_gaussian_input,但需确认 Sphinx/API 文档生成后链接是否仍然有效。

🟢 低风险 / 建议

  1. pre-commit 自动格式化引入的噪音 — Patch 2/2 中 dpdata/plugins/abacus.pydpdata/plugins/cp2k.py 等文件的 import 顺序被 isort 重新排列(如 from dpdata.format import Formatfrom dpdata.formats.abacus.stru import ... 的顺序交换)。这属于纯格式改动,与目录重构无关,虽无危害但增加了 diff 噪音。

  2. 测试覆盖盲区 — PR 描述称"All existing tests pass",但 metadata 中仅更新了 4 个测试文件的 import(tests/context.pytest_abacus_stru_dump.pytest_lammps_lmp_dump.pytest_lammps_spin.pytest_lmdb.py)。如果存在其他测试或示例脚本直接引用旧路径(如 from dpdata.qe.traj import ...),可能未在 CI 中覆盖。


残余风险总结

风险项 说明
外部依赖断裂 第三方代码直接引用旧 import 路径将失效
文档滞后 README、docs、示例 notebook 中的 import 示例可能未同步更新(不在 diff 范围内)
插件生态 若存在外部插件包依赖 dpdata.<format> 路径,同样会断裂

结论

无阻塞性代码问题,但这是一个 breaking change。 若项目遵循语义化版本,此 PR 应触发 minor/major 版本号提升(而非 patch)。建议合并前:

  1. 确认是否需要在根目录添加 deprecated shim 以维持向后兼容;
  2. 检查文档仓库中的 import 示例是否已同步更新;
  3. 在 release note 中明确列出所有受影响的 public import 路径。

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.

[Feature Request] Reorganize the directory structure

1 participant