-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: manage testing models in a standard way #4028
Conversation
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
WalkthroughWalkthroughThe recent changes enhance the testing framework and input handling for the DeepMD library. Key updates include improved tensor reshaping for dimensional consistency, consolidation of model test configurations into YAML files, and restructuring of test classes for streamlined testing processes. These modifications aim to improve maintainability and robustness, aligning with best practices for deep learning workflows while facilitating easier management of model test cases. Changes
Sequence Diagram(s)sequenceDiagram
participant TestSuite
participant CaseManager
participant ModelLoader
TestSuite->>CaseManager: Retrieve test cases
CaseManager->>ModelLoader: Load model based on case
ModelLoader-->>CaseManager: Return model instance
CaseManager-->>TestSuite: Provide model for testing
TestSuite->>TestSuite: Execute test scenarios
Assessment against linked issues
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional comments not posted (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Outside diff range, codebase verification and nitpick comments (22)
source/tests/infer/test_models.py (20)
1-1
: Add a module docstring.Consider adding a module-level docstring to provide an overview of the test module.
2-3
: Remove unnecessary blank line.Remove the unnecessary blank line after the import statement.
- import unittest - + import unittest
4-7
: Remove unnecessary blank line.Remove the unnecessary blank line after the import statement.
- import numpy as np - + import numpy as np
8-10
: Combine import statements.Combine the import statements from the same module into a single statement.
- from deepmd.infer.deep_eval import ( - DeepEval, - ) + from deepmd.infer.deep_eval import DeepEval
11-13
: Combine import statements.Combine the import statements from the same module into a single statement.
- from deepmd.infer.deep_pot import ( - DeepPot, - ) + from deepmd.infer.deep_pot import DeepPot
15-17
: Combine import statements.Combine the import statements from the same module into a single statement.
- from ..consistent.common import ( - parameterized, - ) + from ..consistent.common import parameterized
18-20
: Combine import statements.Combine the import statements from the same module into a single statement.
- from .case import ( - get_cases, - ) + from .case import get_cases
24-28
: Add a docstring for the class.Consider adding a docstring to provide an overview of the test class.
32-38
: Add a docstring for the method.Consider adding a docstring to provide an overview of the setup method.
39-42
: Add a docstring for the method.Consider adding a docstring to provide an overview of the teardown method.
43-51
: Useself.assertIsInstance
instead ofassert
.For consistency and better error messages, use
self.assertIsInstance
instead ofassert
.- assert isinstance(self.dp, DeepPot) + self.assertIsInstance(self.dp, DeepPot)
53-84
: Add a docstring for the method.Consider adding a docstring to provide an overview of the test method.
86-131
: Add a docstring for the method.Consider adding a docstring to provide an overview of the test method.
133-143
: Add a docstring for the method.Consider adding a docstring to provide an overview of the test method.
Tools
Ruff
137-137: Loop control variable
ii
not used within loop bodyRename unused
ii
to_ii
(B007)
145-184
: Rename unused loop variableii
.The loop variable
ii
is not used within the loop body. Rename it to_ii
to indicate that it is unused.- for ii, result in enumerate(self.case.results): + for _ii, result in enumerate(self.case.results):Tools
Ruff
145-145: Loop control variable
ii
not used within loop bodyRename unused
ii
to_ii
(B007)
186-213
: Add a docstring for the method.Consider adding a docstring to provide an overview of the test method.
214-247
: Add a docstring for the method.Consider adding a docstring to provide an overview of the test method.
248-286
: Add a docstring for the method.Consider adding a docstring to provide an overview of the test method.
289-304
: Add a docstring for the class.Consider adding a docstring to provide an overview of the test class.
305-312
: Add a docstring for the method.Consider adding a docstring to provide an overview of the test method.
source/tests/infer/fparam_aparam.yaml (2)
1-7
: Consider adding comments for clarity.Adding comments to explain the purpose of
min_nbor_dist
and its properties can improve readability.
1998-2033
: Consider adding comments for clarity.Adding comments to explain the purpose of each property in the
model_def_script
section can improve readability.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #4028 +/- ##
==========================================
+ Coverage 82.93% 82.95% +0.01%
==========================================
Files 522 522
Lines 51036 51039 +3
Branches 3028 3028
==========================================
+ Hits 42325 42337 +12
+ Misses 7762 7756 -6
+ Partials 949 946 -3 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Outside diff range, codebase verification and nitpick comments (2)
source/tests/infer/test_models.py (2)
25-31
: Class documentation is missing.Consider adding a docstring to the
TestDeepPot
class to describe its purpose and usage.""" Test cases for the DeepPot class. """
321-336
: Class documentation is missing.Consider adding a docstring to the
TestDeepPotNeighborList
class to describe its purpose and usage.""" Test cases for the DeepPot class with neighbor list. """
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Signed-off-by: Jinzhe Zeng <[email protected]>
Fix deepmodeling#2103. Migrate three models (se_e2_a, se_e2_r, and fparam_aparam) for the Python unit tests. Fix several bugs. Old files are kept until the C++ tests are also migrated. Note that several models (for example, the dipole model due to deepmodeling#3672) cannot be serialized yet. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Introduced a structured framework for managing and testing models with YAML files. - Added comprehensive configurations for energy calculations and molecular simulations in YAML format. - Implemented new test cases for the `DeepPot` and `DeepPotNeighborList` classes. - **Bug Fixes** - Improved robustness in tensor reshaping, resolving potential dimension mismatches. - **Tests** - Enhanced unit tests with a case-based approach for better adaptability and maintainability. - Consolidated tests by relocating obsolete classes to streamline the test suite. - **Chores** - Updated deserialization functions for better type safety and input handling. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jinzhe Zeng <[email protected]>
Fix #2103. Migrate three models (se_e2_a, se_e2_r, and fparam_aparam) for the Python unit tests. Fix several bugs. Old files are kept until the C++ tests are also migrated.
Note that several models (for example, the dipole model due to #3672) cannot be serialized yet.
Summary by CodeRabbit
Summary by CodeRabbit
New Features
DeepPot
andDeepPotNeighborList
classes.Bug Fixes
Tests
Chores