deepmodeling / dpgen2

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

Calypso speedup by refactorizing model deviation. #217

Closed wangzyphysics closed 2 months ago

wangzyphysics commented 2 months ago
  1. add a slice when running op run_caly_model_devi
  2. support distanceofion in dict format, e.g. distanceofion = {"Mg": 0.8, "Al": 0.9}, the value denotes the radius of each element, and the mindistance of different element is equal to the sum of value of element Mg and Al and multipy 0.7.
  3. support providing a list of list format name_of_element, e.g. name_of_element = [["Mg", "Al", "Cu", "Li"], ["La", "Ce", "Ca", "Li"], ["H"]], code will randomly choose one of element in each list to set up a input file of calypso.

Summary by CodeRabbit

coderabbitai[bot] commented 2 months ago
Walkthrough ## Walkthrough The recent updates to the `dpgen2` project focus on enhancing Calypso task generation and management, introducing a new operation for preparing model deviations, and refining error handling and logging. These changes include adding new classes, modifying function parameters, and improving task group configurations and testing to streamline processes and enhance flexibility in task parameter handling. ## Changes | File Path | Change Summary | |-----------------------------------------------|--------------------------------------------------------------------------------------------------| | `dpgen2/entrypoint/submit.py` | Added `PrepCalyModelDevi` operation and updated imports. | | `dpgen2/exploration/task/caly_task_group.py` | Updated task parameters handling, including changes to types and optional status of arguments. | | `dpgen2/exploration/task/calypso/caly_input.py` | Updated `atomic_number` parameter's type annotation. | | `dpgen2/exploration/task/make_task_group_from_config.py` | Updated arguments in `caly_task_grp_args` function. | | `dpgen2/op/collect_run_caly.py` | Improved logic for running `calypso`, error handling, and logging. | | `dpgen2/op/prep_caly_dp_optim.py` | Changed logic for determining `group_size` based on dictionary key presence. | | `dpgen2/op/prep_caly_model_devi.py` | Introduced `PrepCalyModelDevi` class for organizing model deviations. | | `dpgen2/superop/prep_run_calypso.py` | Added steps and parameters related to `prep_caly_model_devi_op`. | | `tests/exploration/test_exploration_group.py` | Enhanced testing with new configurations and test methods. | | `tests/mocked_ops.py` | Streamlined logic in the `execute` function for better clarity. | | `tests/op/test_prep_caly_model_devi.py` | Introduced unit tests for the `PrepCalyModelDevi` class. | | `tests/op/test_run_caly_model_devi.py` | Added imports and a new test method for slicing Calypso model deviations. |

Recent Review Details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between 7f0c7e59a6b51ae6b98ac53d5cc8d1833e9b2a3a and 6e447e9b3f9f8c283a400f7d1683847da1dc9da2.
Files selected for processing (4) * dpgen2/entrypoint/submit.py (4 hunks) * dpgen2/exploration/task/caly_task_group.py (4 hunks) * dpgen2/superop/prep_run_calypso.py (5 hunks) * tests/op/test_run_caly_model_devi.py (3 hunks)
Additional Context Used
Ruff (64)
dpgen2/entrypoint/submit.py (34)
2-2: `glob` imported but unused --- 6-6: `pickle` imported but unused --- 16-16: `typing.Type` imported but unused --- 17-17: `typing.Union` imported but unused --- 20-20: `dpdata` imported but unused --- 23-23: `dflow.InputArtifact` imported but unused --- 24-24: `dflow.InputParameter` imported but unused --- 25-25: `dflow.Inputs` imported but unused --- 26-26: `dflow.OutputArtifact` imported but unused --- 27-27: `dflow.OutputParameter` imported but unused --- 28-28: `dflow.Outputs` imported but unused --- 31-31: `dflow.Steps` imported but unused --- 33-33: `dflow.argo_range` imported but unused --- 34-34: `dflow.download_artifact` imported but unused --- 38-38: `dflow.python.OP` imported but unused --- 39-39: `dflow.python.OPIO` imported but unused --- 40-40: `dflow.python.Artifact` imported but unused --- 41-41: `dflow.python.FatalError` imported but unused --- 42-42: `dflow.python.OPIOSign` imported but unused --- 43-43: `dflow.python.PythonOPTemplate` imported but unused --- 44-44: `dflow.python.TransientError` imported but unused --- 45-45: `dflow.python.upload_packages` imported but unused --- 52-52: `dpgen2.constants.default_host` imported but unused --- 65-65: `dpgen2.exploration.report.ExplorationReportTrustLevelsRandom` imported but unused --- 76-76: `dpgen2.exploration.task.CustomizedLmpTemplateTaskGroup` imported but unused --- 78-78: `dpgen2.exploration.task.ExplorationTask` imported but unused --- 79-79: `dpgen2.exploration.task.LmpTemplateTaskGroup` imported but unused --- 80-80: `dpgen2.exploration.task.NPTTaskGroup` imported but unused --- 116-116: `dpgen2.utils.bohrium_config_from_dict` imported but unused --- 117-117: `dpgen2.utils.dump_object_to_file` imported but unused --- 119-119: `dpgen2.utils.load_object_from_file` imported but unused --- 123-123: `dpgen2.utils.workflow_config_from_dict` imported but unused --- 435-435: Local variable `default_config` is assigned to but never used --- 533-533: f-string without any placeholders
dpgen2/exploration/task/caly_task_group.py (1)
126-126: f-string without any placeholders
dpgen2/superop/prep_run_calypso.py (13)
6-6: `pathlib.Path` imported but unused --- 22-22: `dflow.OutputParameter` imported but unused --- 26-26: `dflow.Workflow` imported but unused --- 27-27: `dflow.argo_len` imported but unused --- 28-28: `dflow.argo_range` imported but unused --- 29-29: `dflow.argo_sequence` imported but unused --- 30-30: `dflow.download_artifact` imported but unused --- 31-31: `dflow.upload_artifact` imported but unused --- 35-35: `dflow.python.OPIO` imported but unused --- 36-36: `dflow.python.Artifact` imported but unused --- 37-37: `dflow.python.OPIOSign` imported but unused --- 43-43: `dpgen2.constants.calypso_index_pattern` imported but unused --- 51-51: `.caly_evo_step.CalyEvoStep` imported but unused
tests/op/test_run_caly_model_devi.py (16)
1-1: `os` imported but unused --- 5-5: `ast.Slice` imported but unused --- 11-11: `unittest.mock.Mock` imported but unused --- 12-12: `unittest.mock.call` imported but unused --- 16-16: `numpy` imported but unused --- 24-24: `dflow.Step` imported but unused --- 27-27: `dflow.python.OP` imported but unused --- 29-29: `dflow.python.Artifact` imported but unused --- 30-30: `dflow.python.OPIOSign` imported but unused --- 31-31: `dflow.python.PythonOPTemplate` imported but unused --- 32-32: `dflow.python.TransientError` imported but unused --- 36-36: `dpgen2.constants.calypso_input_file` imported but unused --- 37-37: `dpgen2.constants.calypso_log_name` imported but unused --- 46-46: `dpgen2.utils.BinaryFileInput` imported but unused --- 55-55: `deepmd` imported but unused --- 58-58: Do not use bare `except`
Additional comments not posted (6)
tests/op/test_run_caly_model_devi.py (5)
`1-1`: Remove unused import `os`. --- `5-5`: Remove unused import `Slice`. --- `24-24`: Remove unused import `Step`. --- `31-31`: Remove unused import `PythonOPTemplate`. --- `32-32`: Remove unused import `TransientError`.
dpgen2/exploration/task/caly_task_group.py (1)
`126-126`: The error message in the exception uses an f-string without placeholders, which is redundant. Consider simplifying the string or correctly utilizing the f-string if dynamic data is intended to be included.
--- 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.` 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 a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration 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 2 months ago

Codecov Report

Attention: Patch coverage is 94.50549% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 84.98%. Comparing base (8bdea14) to head (6e447e9).

Files Patch % Lines
dpgen2/entrypoint/submit.py 0.00% 3 Missing :warning:
dpgen2/exploration/task/caly_task_group.py 94.73% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #217 +/- ## ========================================== + Coverage 84.82% 84.98% +0.15% ========================================== Files 93 94 +1 Lines 5034 5114 +80 ========================================== + Hits 4270 4346 +76 - Misses 764 768 +4 ```

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