deepmodeling / dpgen2

2nd generation of the Deep Potential GENerator
https://docs.deepmodeling.com/projects/dpgen2/
GNU Lesser General Public License v3.0
33 stars 26 forks source link

add distance conf filter #250

Closed zjgemi closed 3 months ago

zjgemi commented 3 months ago

Summary by CodeRabbit

coderabbitai[bot] commented 3 months ago
Walkthrough ## Walkthrough The recent changes enhance the `dpgen2` package by introducing advanced configuration filters for customized exploration behaviors. Key updates include the addition of a `filters` parameter in the `lmp_args` and `caly_args` functions, the implementation of multiple filter classes for validating atomic structures, and a streamlined method for handling data within these filters. Overall, these modifications improve user experience and provide greater flexibility in configuration management. ## Changes | Files | Change Summary | |--------------------------------------------------|-------------------------------------------------------------------------------------------------------------| | `dpgen2/entrypoint/args.py` | Added optional `filters` argument to `lmp_args` and `caly_args` functions for enhanced configuration flexibility. Documentation updated. | | `dpgen2/exploration/selector/__init__.py` | Imported new filter classes and defined `conf_filter_styles` dictionary for expanded filtering options. | | `dpgen2/exploration/selector/conf_filter.py` | Modified `check` method in `ConfFilter` to accept a single `frame` parameter, simplifying data handling. | | `dpgen2/exploration/selector/distance_conf_filter.py` | Implemented `DistanceConfFilter`, `BoxSkewnessConfFilter`, and `BoxLengthFilter` classes for validating atomic configurations based on distance and box dimension criteria. | | `tests/exploration/test_conf_filter.py` | Updated `FooFilter` and `faked_filter` classes to streamline `check` method parameters, enhancing clarity and usability. | | `tests/exploration/test_distance_conf_filter.py` | Created a test suite for `DistanceConfFilter`, `BoxSkewnessConfFilter`, and `BoxLengthFilter` using `unittest`, covering both valid and invalid configurations. | ## Sequence Diagram(s) ```mermaid sequenceDiagram participant User participant Args participant Submit participant Scheduler participant Renderer participant DistanceFilter User->>Args: Call lmp_args(filters) Args->>Submit: Pass filters to get_conf_filters() Submit->>Scheduler: Integrate conf_filters Scheduler->>Renderer: Invoke get_confs(conf_filters) Renderer->>DistanceFilter: Validate configurations DistanceFilter-->>Renderer: Return validation result Renderer-->>Scheduler: Return filtered subsystems Scheduler-->>User: Provide exploration results ```

Recent review details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between 40206f4d1b0e50a0a6a7ac69b19526abdab215c4 and d386dac5fa0ded27a35cf5fa0f7a3eedf460b483.
Files selected for processing (1) * dpgen2/exploration/selector/distance_conf_filter.py (1 hunks)
Additional context used
Ruff
dpgen2/exploration/selector/distance_conf_filter.py
126-127: Use a single `if` statement instead of nested `if` statements Combine `if` statements using `and` (SIM102)
Additional comments not posted (5)
dpgen2/exploration/selector/distance_conf_filter.py (5)
`20-118`: **Consider externalizing `safe_dist_dict`.** The `safe_dist_dict` contains hardcoded values. Consider externalizing this data to a configuration file or database to enhance flexibility and maintainability. --- `126-127`: **Combine nested `if` statements.** The nested `if` statements can be combined for better readability. ```diff - if i != j: - if values[i] > multiple * values[j]: + if i != j and values[i] > multiple * values[j]: ```
Tools
Ruff
126-127: Use a single `if` statement instead of nested `if` statements Combine `if` statements using `and` (SIM102)
--- `135-218`: **Enhance `DistanceConfFilter` with logging and configuration.** The `DistanceConfFilter` class uses print statements for output. Replace these with logging for better control and integration with logging systems. Additionally, consider externalizing configuration values like `safe_dist_dict`. --- `220-273`: **Replace print statements with logging in `BoxSkewnessConfFilter`.** Replace the print statement with logging to provide better control over the output. ```diff - print("Inclined box") + logger.warning("Inclined box") ``` --- `276-329`: **Replace print statements with logging in `BoxLengthFilter`.** Replace the print statement with logging to provide better control over the output. ```diff - print("One side is %s larger than another" % self.length_ratio) + logger.warning("One side is %s larger than another", self.length_ratio) ```
--- 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?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` 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) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 89.74359% with 12 lines in your changes missing coverage. Please review.

Project coverage is 83.87%. Comparing base (c0f83c7) to head (d386dac). Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
dpgen2/entrypoint/submit.py 50.00% 6 Missing :warning:
dpgen2/exploration/render/traj_render_lammps.py 14.28% 6 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #250 +/- ## ========================================== + Coverage 83.75% 83.87% +0.12% ========================================== Files 97 98 +1 Lines 5318 5433 +115 ========================================== + Hits 4454 4557 +103 - Misses 864 876 +12 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features: