You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: support using train/valid data from input.json for dp test (#4859)
This pull request extends the testing functionality in DeepMD by
allowing users to specify training and validation data directly via
input JSON files, in addition to existing system and datafile options.
It updates the command-line interface, the main test logic, and adds
comprehensive tests to cover these new features, including support for
recursive glob patterns when selecting systems from JSON files.
### Feature enhancements to testing data sources
* The `test` function in `deepmd/entrypoints/test.py` now accepts
`train_json` and `valid_json` arguments, allowing users to specify
training or validation systems for testing via input JSON files. It
processes these files to extract system paths, including support for
recursive glob patterns. The function also raises an error if no valid
data source is specified.
[[1]](diffhunk://#diff-299c01ed4ee7d0b3f636fe4cb4f0d660a5012b7e95ca0740098b3ace617ab16eL61-R71)
[[2]](diffhunk://#diff-299c01ed4ee7d0b3f636fe4cb4f0d660a5012b7e95ca0740098b3ace617ab16eL104-R151)
* **The command-line interface in `deepmd/main.py` is updated to add
`--train-data` and `--valid-data` arguments for the test subparser,
enabling direct specification of input JSON files for training and
validation data.**
### Test coverage improvements
* New and updated tests in `source/tests/pt/test_dp_test.py` verify the
ability to run tests using input JSON files for both training and
validation data, including cases with recursive glob patterns. This
ensures robust handling of various data source configurations.
[[1]](diffhunk://#diff-ce70e95ffdb1996c7887ea3f63b54d1ae0fef98059572ad03875ca36cfef3c34L33-R35)
[[2]](diffhunk://#diff-ce70e95ffdb1996c7887ea3f63b54d1ae0fef98059572ad03875ca36cfef3c34R49-R59)
[[3]](diffhunk://#diff-ce70e95ffdb1996c7887ea3f63b54d1ae0fef98059572ad03875ca36cfef3c34R103-R116)
[[4]](diffhunk://#diff-ce70e95ffdb1996c7887ea3f63b54d1ae0fef98059572ad03875ca36cfef3c34R164-R273)
* Additional argument parser tests in
`source/tests/common/test_argument_parser.py` confirm correct parsing of
the new `--train-data` and `--valid-data` options.
### Internal code improvements
* Refactored imports and type annotations in
`deepmd/entrypoints/test.py` to support the new functionality and
improve code clarity.
[[1]](diffhunk://#diff-299c01ed4ee7d0b3f636fe4cb4f0d660a5012b7e95ca0740098b3ace617ab16eR17)
[[2]](diffhunk://#diff-299c01ed4ee7d0b3f636fe4cb4f0d660a5012b7e95ca0740098b3ace617ab16eR42-R50)
[[3]](diffhunk://#diff-299c01ed4ee7d0b3f636fe4cb4f0d660a5012b7e95ca0740098b3ace617ab16eL77-R95)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Added support for supplying test systems via JSON files, including
selecting training or validation data.
- Introduced CLI options --train-data and --valid-data for the test
command.
- Supports resolving relative paths from JSON and optional recursive
glob patterns.
- Changes
- Test command now requires at least one data source (JSON, data file,
or system); clearer errors when none or no systems found.
- Tests
- Expanded test coverage for JSON-driven inputs and recursive glob
patterns; refactored helpers for improved readability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Chun Cai <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
0 commit comments