fix(dpdata): read newer CP2K output with dpdata's cp2k/output parser - #23
Open
ChiahsinChu wants to merge 1 commit into
Open
ChiahsinChu wants to merge 1 commit into
ChiahsinChu wants to merge 1 commit into
Conversation
`tool dpdata read --fmt cp2k/output` failed on CP2K 2025 ENERGY_FORCE output with "unsupported operand type(s) for *: 'NoneType' and 'float'". cp2kdata's dpdata plugin re-registers "cp2k/output" and its parser cannot read the new layout (ENERGY| ... [hartree], FORCES| block). dpdata >= 1.1.0's built-in parser handles it, so re-register it in register_data_types(), which every cp2k/output call site runs through. Outputs match the previous cp2kdata parser on older CP2K versions. Require dpdata >= 1.1.0 on python >= 3.10 (keep 0.2.18 on 3.9, which dpdata 1.1.0 no longer supports) and regenerate poetry.lock. The lock also picks up oh-my-batch 0.7.6, already required by pyproject.toml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ai2-kit tool dpdata read <out> --fmt cp2k/outputfails on CP2K 2025.2 ENERGY_FORCE output:The format name is taken over by another package. cp2kdata's dpdata plugin (0.7.3, the latest release) registers its own parser under
cp2k/output(andcp2k/aimd_output), which overrides dpdata's built-in parser whenever cp2kdata is installed. cp2kdata cannot read the newer output layout (ENERGY| ... energy [hartree],FORCES|block), so it returnsNonefor the energy.dpdata's built-in parser handles this layout from dpdata 1.1.0 (deepmodeling/dpdata#978). ai2-kit, however, pins
dpdata = "0.2.18", which also fails on it (cannot find forces).Change
ai2_kit/tool/dpdata.py:register_data_types()now re-registers dpdata'sCP2KOutputFormatundercp2k/output. Everycp2k/outputcall site goes through this function, either throughai2_kit.tool.dpdataor throughdomain/deepmd.py.cp2k/aimd_outputis left with cp2kdata.pyproject.toml: requiredpdata >= 1.1.0on Python >= 3.10. Python 3.9 stays on 0.2.18, because dpdata 1.1.0 requires Python >= 3.10.poetry.lock: regenerated withpoetry lock --no-update(Poetry 1.8.3). This also picks up oh-my-batch 0.7.6, whichpyproject.tomlalready requires (>=0.7.0) but the old lock still had at 0.6.1. The per-packageustcsource entries are gone because packages now resolve from the primary PyPI source.Is anything lost by not using cp2kdata for
cp2k/output?I compared both parsers on dpdata's CP2K test outputs (CP2K 6.1, 7.1 and a synthetic 2025.1) and on a CP2K 2022.1 output. On every file cp2kdata can read, energies, forces, coordinates, cells, virials and atom names are identical. Two differences remain:
STRESS| Analytical stress tensor [GPa]block, while dpdata ≤ 1.1.0 only reads the legacy block. feat(cp2k): parse STRESS| stress tensor block in cp2k/output deepmodeling/dpdata#1062 adds this, including[bar], CP2K's default unit.true_symbols=Trueoption is silently ignored. ai2-kit doesn't pass it.Testing
In a Python 3.11 env with dpdata 1.1.0 and cp2kdata 0.7.3 installed:
ai2-kit tool dpdata read cp2k.2025.2.out --fmt cp2k/output - write outnow works: 906 atoms, E = −262255.859 eV. It matches an independent ASE-based parser to 2.5e-8 eV/Å in forces. A CP2K 2022.1 output parses as before.tests/test_data.pyandtests/test_dplr.py:test_dpdata_to_asenow passes (it failed before under cp2kdata). The twoTestDPFFDPDatafailures come fromdeepmdnot being installed and happen onmaintoo.poetry check --lock: OK.🤖 Generated with Claude Code