feat: add cp2k support for skipping bad box#1830
feat: add cp2k support for skipping bad box#1830wanghan-iapcm merged 4 commits intodeepmodeling:develfrom
Conversation
📝 WalkthroughWalkthroughAdds an fp_skip_bad_box option to make_fp_cp2k that validates each task POSCAR with check_bad_box, skips and counts bad configurations, logs a skip summary after processing, removes redundant fp.close() calls, and continues linking PP files for processed tasks. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant make_fp_cp2k as make_fp_cp2k()
participant check_bad_box
participant _link_fp_vasp_pp
participant Logger
Caller->>make_fp_cp2k: invoke (may include fp_skip_bad_box)
make_fp_cp2k->>make_fp_cp2k: iterate tasks
rect rgba(200,220,255,0.6)
note right of make_fp_cp2k: Per-task validation when fp_skip_bad_box set
make_fp_cp2k->>check_bad_box: validate POSCAR
alt bad box detected
check_bad_box-->>make_fp_cp2k: True
make_fp_cp2k->>make_fp_cp2k: increment count_bad_box and skip task
else valid box
check_bad_box-->>make_fp_cp2k: False
make_fp_cp2k->>make_fp_cp2k: generate inputs (input.inp, coord.xyz)
make_fp_cp2k->>_link_fp_vasp_pp: link PP files for task
end
end
make_fp_cp2k->>Logger: log skip summary (skipped vs remaining)
make_fp_cp2k-->>Caller: return
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)dpgen/{generator,auto_test,data,simplify}/**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (1)dpgen/generator/run.py (1)
🔇 Additional comments (2)
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. Comment |
Signed-off-by: Ming-Yu Guo <gmy721212@163.com>
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
dpgen/generator/run.py (1)
3658-3670: Move bad box check before reading sys_data for better performance.Currently,
sys_data = dpdata.System("POSCAR").datais read for all tasks (line 3660), but ifskip_bad_boxis set and the box is bad,sys_datais never used. The bad box check happens afterward (lines 3663-3670).For efficiency, consider checking the bad box first, then only reading
sys_dataif the task won't be skipped:for ii in fp_tasks: os.chdir(ii) + + if skip_bad_box is not None: + # Check the box directly from POSCAR + skip = check_bad_box("POSCAR", skip_bad_box, fmt="vasp/poscar") + if skip: + count_bad_box += 1 + os.chdir(cwd) + continue + sys_data = dpdata.System("POSCAR").data # make input for every task # if fp_params exits, make keys - if skip_bad_box is not None: - # Check the box directly from POSCAR - skip = check_bad_box("POSCAR", skip_bad_box, fmt="vasp/poscar") - if skip: - count_bad_box += 1 - os.chdir(cwd) - continue - if fp_params:This avoids unnecessary POSCAR parsing for tasks that will be skipped.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
dpgen/generator/run.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
dpgen/{generator,auto_test,data,simplify}/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Place core logic changes in the appropriate module directories: dpgen/generator, dpgen/auto_test, dpgen/data, dpgen/simplify
Files:
dpgen/generator/run.py
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Adhere to ruff linting for Python code as configured in the repository
Use isort with the Black profile for import ordering in Python files
Write Numpy-style docstrings for Python code
Ensure code remains compatible with Python 3.9–3.12 (as per CI matrix)
Files:
dpgen/generator/run.py
🧬 Code graph analysis (1)
dpgen/generator/run.py (1)
dpgen/generator/lib/cp2k.py (3)
make_cp2k_input(286-322)make_cp2k_input_from_external(340-369)make_cp2k_xyz(325-337)
🔇 Additional comments (2)
dpgen/generator/run.py (2)
3654-3657: LGTM! Clean initialization of skip_bad_box mechanism.The initialization is straightforward and uses
.get()appropriately for the optional parameter.
3684-3687: LGTM! Summary logging is clear and consistent with existing patterns.The summary message format matches the pattern used in
_make_fp_vasp_inner(lines 2944-2947), maintaining consistency across the codebase. The logging provides useful information about how many configurations were skipped and how many remain for FP calculations.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
dpgen/generator/run.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
dpgen/{generator,auto_test,data,simplify}/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Place core logic changes in the appropriate module directories: dpgen/generator, dpgen/auto_test, dpgen/data, dpgen/simplify
Files:
dpgen/generator/run.py
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Adhere to ruff linting for Python code as configured in the repository
Use isort with the Black profile for import ordering in Python files
Write Numpy-style docstrings for Python code
Ensure code remains compatible with Python 3.9–3.12 (as per CI matrix)
Files:
dpgen/generator/run.py
🧬 Code graph analysis (1)
dpgen/generator/run.py (1)
dpgen/generator/lib/cp2k.py (3)
make_cp2k_input(286-322)make_cp2k_input_from_external(340-369)make_cp2k_xyz(325-337)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #1830 +/- ##
==========================================
- Coverage 49.81% 49.80% -0.02%
==========================================
Files 83 83
Lines 14978 14988 +10
==========================================
+ Hits 7462 7465 +3
- Misses 7516 7523 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
related to #1816 |
Summary by CodeRabbit
New Features
Improvements
Bug Fixes