Skip to content

fix(dpdata): use public format APIs#1880

Merged
njzjz merged 1 commit into
deepmodeling:masterfrom
njzjz-bot:fix-dpdata-1-imports
May 8, 2026
Merged

fix(dpdata): use public format APIs#1880
njzjz merged 1 commit into
deepmodeling:masterfrom
njzjz-bot:fix-dpdata-1-imports

Conversation

@njzjz-bot
Copy link
Copy Markdown
Contributor

@njzjz-bot njzjz-bot commented May 8, 2026

Problem

  • dpdata 1.0 removes legacy backend import paths such as dpdata.abacus.stru, which breaks DP-GEN imports with the latest dpdata release.
  • Directly importing backend parser modules is brittle across dpdata releases; DP-GEN should use dpdata's registered public format interface instead.

Change

  • Replace direct ABACUS STRU and VASP POSCAR helper imports with dpdata.System(..., fmt=...) / System.to(...) calls.
  • Replace direct SIESTA output parsing with dpdata.LabeledSystem(..., fmt="siesta/output").
  • Keep the ABACUS SCF type_map path compatible with dpdata 1.x by normalizing atom_types before applying the type map.

Test

  • With dpdata==1.0.2: python -m pytest tests/data/test_disturb_abacus.py tests/auto_test/test_abacus.py tests/generator/test_post_fp.py::TestPostFPABACUS::test_nframs_with_failed_job tests/generator/test_post_fp.py::TestPostFPSIESTA -q
  • With dpdata==0.2.25: same targeted pytest command above.
  • uvx ruff check dpgen/auto_test/lib/abacus.py dpgen/generator/lib/abacus_scf.py dpgen/generator/run.py

Authored by OpenClaw (model: gpt-5.5)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request refactors import paths across three modules to use dpdata's new formats namespace. ABACUS STRU and VASP POSCAR imports are updated in auto_test/lib/abacus.py and abacus_scf.py. SIESTA output parsing imports and usage are updated in run.py. No logic changes occur.

Changes

dpdata Import Path Migration

Layer / File(s) Summary
Abacus Import Refactoring
dpgen/auto_test/lib/abacus.py, dpgen/generator/lib/abacus_scf.py
Imports for make_unlabeled_stru and poscar are migrated from dpdata.abacus.stru and dpdata.vasp to dpdata.formats.abacus.stru and dpdata.formats.vasp respectively.
SIESTA Import and Usage Update
dpgen/generator/run.py
Import for dpdata.formats.siesta.output is added, and the obtain_frame(...) call site in the FP post-processing is updated to use the new module path.

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(dpdata): use public format APIs' accurately summarizes the main change - updating DP-GEN to use dpdata's new public format module paths instead of legacy imports.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@njzjz-bot njzjz-bot force-pushed the fix-dpdata-1-imports branch from 538c76d to 9bff68b Compare May 8, 2026 02:32
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.80%. Comparing base (f4f74a2) to head (1053cfd).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1880      +/-   ##
==========================================
- Coverage   49.81%   49.80%   -0.01%     
==========================================
  Files          83       83              
  Lines       14988    14986       -2     
==========================================
- Hits         7466     7464       -2     
  Misses       7522     7522              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@dpgen/generator/lib/abacus_scf.py`:
- Line 6: The import path is wrong: replace the non-existent module
dpdata.formats.abacus.stru with dpdata.abacus.stru wherever get_frame_from_stru
and make_unlabeled_stru are imported (e.g., in the module that currently imports
from dpdata.formats.abacus.stru and the similar import in the other test
module). Update the import statement to import get_frame_from_stru and
make_unlabeled_stru from dpdata.abacus.stru so the runtime can find those
symbols.

In `@dpgen/generator/run.py`:
- Line 32: The import dpdata.formats.siesta.output is invalid and should be
changed to dpdata.siesta.output; update the import statement in
dpgen/generator/run.py to import from dpdata.siesta.output and ensure any
references that expect the old package path (the code that uses the siesta
output module later in this file) continue to refer to the same symbols from the
corrected import; this fixes the ImportError when importing dpgen.generator.run.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a4f52112-0576-4de0-9ae8-9490252c1365

📥 Commits

Reviewing files that changed from the base of the PR and between f4f74a2 and 538c76d.

📒 Files selected for processing (3)
  • dpgen/auto_test/lib/abacus.py
  • dpgen/generator/lib/abacus_scf.py
  • dpgen/generator/run.py

Comment thread dpgen/generator/lib/abacus_scf.py Outdated
Comment thread dpgen/generator/run.py Outdated
@njzjz-bot njzjz-bot force-pushed the fix-dpdata-1-imports branch from 21afda3 to 63e9bbc Compare May 8, 2026 02:36
Avoid importing dpdata backend parser modules directly. Use dpdata's registered public format interface for ABACUS STRU, VASP POSCAR, and SIESTA output handling so DP-GEN works with both dpdata 0.2.x and 1.x without depending on moved backend module paths.

Authored by OpenClaw (model: gpt-5.5)
@njzjz-bot njzjz-bot force-pushed the fix-dpdata-1-imports branch from 876dfae to 1053cfd Compare May 8, 2026 03:06
@njzjz-bot njzjz-bot changed the title fix(dpdata): use new format module paths fix(dpdata): use public format APIs May 8, 2026
@njzjz njzjz requested a review from wanghan-iapcm May 8, 2026 05:13
@njzjz njzjz merged commit d25b6ce into deepmodeling:master May 8, 2026
8 checks passed
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.

2 participants