deepmodeling / dpdata

Manipulating multiple atomic simulation data formats, including DeePMD-kit, VASP, LAMMPS, ABACUS, etc.
https://docs.deepmodeling.com/projects/dpdata/
GNU Lesser General Public License v3.0
188 stars 128 forks source link

Adding a function that could deal with the magnetic_force and spin when using the ABACUS's deltaspin module #657

Closed flinky-ai closed 4 weeks ago

flinky-ai commented 1 month ago

Adding a new function, two files were changed.

I add three parameters in the data when reading data from the OUT.ABACUS/running_scf.log.

When we use the deltaspin module during the scf calculation, the dpdata could grep the magnetic force and spin to the system and print the modified coords.npy and forces.npy.

Summary by CodeRabbit

coderabbitai[bot] commented 1 month ago

Walkthrough

The recent update focuses on code quality improvements, reorganization, and minor functional enhancements across multiple files. Key changes include fixing import statements, reformatting code, and adding new functions to handle specific data in the abacus module. Additionally, the .pre-commit-config.yaml and .gitattributes files have been updated for better code management and consistency in line endings.

Changes

File(s) Change Summary
dpdata/plugins/3dmol.py Corrected import statement for py3Dmol and fixed indexing in types.
dpdata/plugins/__init__.py Reordered and reformatted import statements.
dpdata/plugins/abacus.py, dpdata/abacus/scf.py Reorganized imports, adjusted indentation, updated method calls, and added new functions for handling magnetic and spin data.
dpdata/plugins/amber.py Adjusted method signatures in AmberMDFormat and from_labeled_system.
dpdata/plugins/ase.py Removed from __future__ import annotations, adjusted type annotations, and reorganized imports.
dpdata/plugins/cp2k.py, dpdata/plugins/dftbplus.py, dpdata/plugins/fhi_aims.py, dpdata/plugins/gaussian.py Made formatting and spacing adjustments.
dpdata/plugins/deepmd.py Refactored code by removing redundant imports and adjusting method signatures.
dpdata/deepmd/comp.py Added coords_deltaspin parameter and handling for force_deltaspin in the dump function.
.pre-commit-config.yaml Updated URLs and revisions for repositories, adjusted comments, and reformatted file structure.
.gitattributes Added *.py test eol=lf pattern for line endings.

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.
flinky-ai commented 1 month ago

@amcadmus @chazeon I cloned the original dpdata code into my local space. But failed to pip install with these codes. Now, I add some function into the dpdata to deal with the deltaspin_scf abacus calculation results. And now, it failed with the PR process. I checked my code. It should be workable. Could you please help me with it?

Defaulting to user installation because normal site-packages is not writeable
Processing /mnt/d/AISI/dpdata
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: UNKNOWN
  Building wheel for UNKNOWN (pyproject.toml) ... done
  Created wheel for UNKNOWN: filename=UNKNOWN-0.2.19.dev20+ge1f02fd.d20240515-py3-none-any.whl size=4091 sha256=85056635321a8add11d86137b7469a82fa56dd77b985682e5def93568b00e9df
  Stored in directory: /tmp/pip-ephem-wheel-cache-9kbvnwiy/wheels/00/6a/08/3bb0e14df3403c9233763f1104d7951eb1cd83c31155a6d7b0
Successfully built UNKNOWN
Installing collected packages: UNKNOWN
  Attempting uninstall: UNKNOWN
    Found existing installation: UNKNOWN 0.1.dev698+g658a511
    Uninstalling UNKNOWN-0.1.dev698+g658a511:
      Successfully uninstalled UNKNOWN-0.1.dev698+g658a511
Successfully installed UNKNOWN-0.2.19.dev20+ge1f02fd.d20240515
chazeon commented 1 month ago

The failed CI build seems to come from readthedocs, due to Python 3.12:

The readthedocs build environment is recently updated; see #655. You could try to rebase to the devel branch first, then change the PR target to devel.

For your local install, you need to clean up your workspace; it seems to be reading the package info from the PKG-INFO you created in your earlier commits.

Finally, I would suggest you include a test example with spins in your PR.

codecov[bot] commented 1 month ago

Codecov Report

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

Project coverage is 83.47%. Comparing base (1d87e82) to head (361b293).

Files Patch % Lines
dpdata/abacus/scf.py 20.96% 49 Missing :warning:
dpdata/deepmd/comp.py 64.28% 5 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## devel #657 +/- ## ========================================== - Coverage 84.06% 83.47% -0.59% ========================================== Files 81 81 Lines 7122 7196 +74 ========================================== + Hits 5987 6007 +20 - Misses 1135 1189 +54 ```

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

codspeed-hq[bot] commented 1 month ago

CodSpeed Performance Report

Merging #657 will not alter performance

Comparing flinky-ai:my-fix-branch (361b293) with devel (1d87e82)

Summary

✅ 2 untouched benchmarks

flinky-ai commented 1 month ago

The failed CI build seems to come from readthedocs, due to Python 3.12:

The readthedocs build environment is recently updated; see #655. You could try to rebase to the devel branch first, then change the PR target to devel.

For your local install, you need to clean up your workspace; it seems to be reading the package info from the PKG-INFO you created in your earlier commits.

Finally, I would suggest you include a test example with spins in your PR.

I used the pip -vvv install . and found the details of my installation while install the cloned dpdata locally. And it seems to be the reason that my setuptools version is not replaced by the newly installed setputools-69.5.1. The problem is solved by upgrading setuptools manually.

Successfully installed packaging-24.0 setuptools-69.5.1 setuptools_scm-8.1.0 tomli-2.0.1
  Installing build dependencies ... done
  Running command Getting requirements to build wheel
  /tmp/pip-build-env-nvbne_99/overlay/local/lib/python3.10/dist-packages/setuptools_scm/_integration/setuptools.py:31: RuntimeWarning:
  ERROR: setuptools==59.6.0 is used in combination with setuptools_scm>=8.x

  Your build configuration is incomplete and previously worked by accident!
  setuptools_scm requires setuptools>=61
:/mnt/d/AISI/dpdata$ pip3 install --upgrade pip setuptools
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /usr/lib/python3/dist-packages (22.0.2)
Collecting pip
  Downloading pip-24.0-py3-none-any.whl (2.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 15.1 kB/s eta 0:00:00
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (59.6.0)
Collecting setuptools
  Using cached setuptools-69.5.1-py3-none-any.whl (894 kB)
Installing collected packages: setuptools, pip
Successfully installed pip-24.0 setuptools-69.5.1
flinky-ai commented 1 month ago

It looks like you changed the line ending of each file from LF to CRLF, which should be reverted

I don't know in what step led me to make this mistake. I will change the format and resubmit again.