Skip to content

fix(vasp): report frames dropped for a missing OUTCAR energy - #1047

Open
njzjz wants to merge 1 commit into
deepmodeling:masterfrom
njzjz:fix/issue-566
Open

fix(vasp): report frames dropped for a missing OUTCAR energy#1047
njzjz wants to merge 1 commit into
deepmodeling:masterfrom
njzjz:fix/issue-566

Conversation

@njzjz

@njzjz njzjz commented Jul 27, 2026

Copy link
Copy Markdown
Member

Ref #566.

State of the issue

The crash in the report — TypeError: Mismatch between array dtype ('object') and format specifier ('%.18e') from np.savetxt — no longer reproduces. #844 added a None guard in _get_frames_lower, so a truncated OUTCAR now yields a clean float64 energies array. I confirmed this by cutting tests/poscars/OUTCAR.h2o.md just before its last TOTEN record: 2 frames, dtype('float64'), no exception.

What #844 left behind is a bare break:

if energy is None:
    break

So the damaged frame and every frame after it vanish with no diagnostic at all. A user converting an interrupted run silently gets fewer frames than the run produced, which is the half of njzjz's comment ("there should be an error, or dpdata should ignore the frame") that is still unaddressed.

Change

Warn before breaking, naming the frame and stating that nothing after it is read either:

UserWarning: no energy found in frame 3; it and any frame after it are not read.
This usually means the calculation was interrupted before it finished writing.

The same break is also the normal loop exit — after the last ionic step, get_outcar_block returns the trailing timing report, which has no energy either. Warning unconditionally would fire on every well-formed OUTCAR (this is what my first attempt did, and test_complete_file_is_silent caught it). The warning is therefore limited to blocks that had already started emitting step data, i.e. where coord, cell, or force is non-empty.

No parsed data changes; this is purely diagnostic.

Validation

  • tests/test_vasp_outcar_interrupted.py, 4 new cases: a complete file stays silent, a file cut before the last TOTEN warns naming frame 3, the surviving frames keep their exact energies and coordinates, and the energies array stays float64 (a direct regression test for the dtype in the original traceback).
  • python -m unittest discover — 2240 passed, 28 skipped.
  • ruff format / ruff check clean.

On closing the issue

This PR says Ref rather than Fixes because #566 was filed against dpgen with awaiting response and the reporter never came back. The reported crash is gone as of #844 and this closes the silent-data-loss gap it left. Happy to switch to Fixes if you would rather close it out.

🤖 Generated with Claude Code

An interrupted VASP run leaves a trailing ionic step with no TOTEN
record. deepmodeling#844 stopped that from appending a `None` energy, which was the
crash in the original report, but the replacement is a bare `break`: the
frame and everything after it disappear with no diagnostic, so a
truncated OUTCAR just quietly yields fewer frames than the run produced.

Warn when that happens, naming the frame and saying that nothing after it
is read either. Reaching the same `break` at the trailing timing report
after the last ionic step is the normal exit, so the warning is limited
to blocks that had already started emitting step data.

Ref deepmodeling#566.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 27, 2026 06:09
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. vasp labels Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@njzjz, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6cee5ed7-c167-4163-a6fd-1673bb4b0da1

📥 Commits

Reviewing files that changed from the base of the PR and between c77e038 and 5896cb1.

📒 Files selected for processing (2)
  • dpdata/formats/vasp/outcar.py
  • tests/test_vasp_outcar_interrupted.py

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.

@codspeed-hq

codspeed-hq Bot commented Jul 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 2 untouched benchmarks


Comparing njzjz:fix/issue-566 (5896cb1) with master (c77e038)

Open in CodSpeed

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.63%. Comparing base (c77e038) to head (5896cb1).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1047   +/-   ##
=======================================
  Coverage   87.63%   87.63%           
=======================================
  Files          90       90           
  Lines        9209     9211    +2     
=======================================
+ Hits         8070     8072    +2     
  Misses       1139     1139           

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves VASP OUTCAR robustness in dpdata by emitting a targeted warning when an OUTCAR ends with an ionic step that has started producing step data (coords/cell/forces) but never records a TOTEN energy, which would otherwise cause silent frame loss at the end of the trajectory.

Changes:

  • Add a conditional UserWarning before breaking out of OUTCAR frame parsing when energy is None for a block that already contains step data, indicating the dropped frame number and that subsequent frames cannot be read.
  • Add a focused unittest module covering both the “complete OUTCAR should not warn” case and the “truncated before final TOTEN should warn and preserve prior frames/dtypes” regressions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
dpdata/formats/vasp/outcar.py Adds a conditional warning when the final (or truncated) block contains step data but lacks an energy token, avoiding silent frame truncation.
tests/test_vasp_outcar_interrupted.py Adds regression tests ensuring complete OUTCARs stay quiet and truncated OUTCARs warn while keeping earlier frames intact and energies float64.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

size:S This PR changes 10-29 lines, ignoring generated files. vasp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants