Skip to content
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

feat: add plugin entry point for PT #3965

Merged
merged 1 commit into from
Jul 11, 2024
Merged

Conversation

njzjz
Copy link
Member

@njzjz njzjz commented Jul 10, 2024

Currently, we have it for TF, for the backend, but not for PT.

Summary by CodeRabbit

  • Documentation

    • Updated guidelines for packaging new codes into a Python package for DeePMD-kit, including changes to use pyproject.toml instead of setup.py.
  • Refactor

    • Improved entry point loading by centralizing the logic into a new utility function, enhancing code maintainability and readability.

Currently, we have it for TF, for the backend, but not for PT.

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Copy link
Contributor

coderabbitai bot commented Jul 10, 2024

Walkthrough

Walkthrough

The recent changes in the DeePMD-kit project primarily focus on refactoring the mechanism for loading entry points. A new utility function, load_entry_point, has been introduced in deepmd/utils/entry_point.py to streamline this process. Various modules within the project now utilize this function instead of their previous entry point loading logic. Additionally, documentation updates reflect the transition to using pyproject.toml for packaging configurations.

Changes

File Path Summary
deepmd/backend/__init__.py Refactored to use load_entry_point from deepmd.utils.entry_point.
deepmd/pt/model/__init__.py Updated to import and use load_entry_point from deepmd.utils.entry_point.
deepmd/tf/__init__.py Modified to import load_entry_point from deepmd.utils.entry_point.
deepmd/utils/entry_point.py Introduced a new function load_entry_point to load entry points based on group names.
doc/development/create-a-model-pt.md Updated instructions for packaging new codes into a Python package using pyproject.toml.
doc/development/create-a-model-tf.md Revised documentation for packaging new codes using pyproject.toml instead of setuptools.

Sequence Diagram(s)

The changes are primarily refactoring and documentation updates, so no sequence diagrams are necessary.

Tip

You can generate walkthrough under a collapsible section

Enable the reviews.collapse_walkthrough setting in your project's settings in CodeRabbit to generate walkthrough in a markdown collapsible section.


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b86165d and 2a9a179.

Files selected for processing (6)
  • deepmd/backend/init.py (2 hunks)
  • deepmd/pt/model/init.py (1 hunks)
  • deepmd/tf/init.py (2 hunks)
  • deepmd/utils/entry_point.py (1 hunks)
  • doc/development/create-a-model-pt.md (1 hunks)
  • doc/development/create-a-model-tf.md (1 hunks)
Files skipped from review due to trivial changes (3)
  • deepmd/pt/model/init.py
  • doc/development/create-a-model-pt.md
  • doc/development/create-a-model-tf.md
Additional comments not posted (5)
deepmd/backend/__init__.py (2)

15-17: LGTM! Import statement correctly updated.

The import statement now includes load_entry_point from deepmd.utils.entry_point, which is appropriate for the new functionality.


27-27: LGTM! Usage of load_entry_point is correct.

The load_entry_point function is correctly called to load the entry points for deepmd.backend.

Verification successful

Verification Successful: load_entry_point usage is correct.

The load_entry_point function is defined in deepmd/utils/entry_point.py and is used appropriately across multiple modules, including deepmd/backend/__init__.py.

  • Definition: deepmd/utils/entry_point.py
  • Usages:
    • deepmd/pt/model/__init__.py
    • deepmd/tf/__init__.py
    • deepmd/backend/__init__.py
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and usage of `load_entry_point` in the codebase.

# Test: Search for the function definition. Expect: Only one occurrence of the function definition.
ast-grep --lang python --pattern $'def load_entry_point(group: str) -> list' 

# Test: Search for the function usage. Expect: Only occurances of the new usage.
rg --type python -A 5 $'load_entry_point'

Length of output: 494


Script:

#!/bin/bash
# Description: Re-verify the definition and usage of `load_entry_point` in the codebase.

# Test: Search for the function definition. Refine the pattern to ensure correctness.
ast-grep --lang python --pattern $'def load_entry_point($_) -> $_'

# Test: Search for the function usage. Correct the file type for Python.
rg --type py -A 5 'load_entry_point'

Length of output: 1663

deepmd/utils/entry_point.py (1)

2-4: LGTM! Import statement correctly added.

The import statement now includes metadata from importlib, which is necessary for the new functionality.

deepmd/tf/__init__.py (2)

5-7: LGTM! Import statement correctly updated.

The import statement now includes load_entry_point from deepmd.utils.entry_point, which is appropriate for the new functionality.


38-38: LGTM! Usage of load_entry_point is correct.

The load_entry_point function is correctly called to load the entry points for deepmd.tf.

Verification successful

Verified: The load_entry_point function is correctly used in deepmd/tf/__init__.py and other modules. The function definition in deepmd/utils/entry_point.py matches the usage patterns observed.

  • deepmd/tf/__init__.py: load_entry_point("deepmd")
  • deepmd/pt/model/__init__.py: load_entry_point("deepmd.pt")
  • deepmd/backend/__init__.py: load_entry_point("deepmd.backend")
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and usage of `load_entry_point` in the codebase.

# Test: Search for the function definition. Expect: Only one occurrence of the function definition.
ast-grep --lang python --pattern $'def load_entry_point(group: str) -> list' 

# Test: Search for the function usage. Expect: Only occurances of the new usage.
rg --type python -A 5 $'load_entry_point'

Length of output: 494


Script:

#!/bin/bash
# Description: Verify the definition and usage of `load_entry_point` in the codebase.

# Test: Search for the function definition. Expect: Only one occurrence of the function definition.
ast-grep --lang python --pattern 'def load_entry_point($_) -> $_:'

# Test: Search for the function usage. Expect: Only occurrences of the new usage.
rg 'load_entry_point' --type py -A 5

Length of output: 1319


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
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • 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 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

deepmd/utils/entry_point.py Show resolved Hide resolved
Copy link

codecov bot commented Jul 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.84%. Comparing base (b86165d) to head (2a9a179).
Report is 110 commits behind head on devel.

Additional details and impacted files
@@           Coverage Diff           @@
##            devel    #3965   +/-   ##
=======================================
  Coverage   82.83%   82.84%           
=======================================
  Files         520      522    +2     
  Lines       50832    50829    -3     
  Branches     3015     3015           
=======================================
- Hits        42109    42107    -2     
+ Misses       7788     7784    -4     
- Partials      935      938    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wanghan-iapcm wanghan-iapcm added this pull request to the merge queue Jul 11, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 11, 2024
@njzjz njzjz added this pull request to the merge queue Jul 11, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 11, 2024
@njzjz njzjz added this pull request to the merge queue Jul 11, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 11, 2024
@njzjz njzjz added this pull request to the merge queue Jul 11, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 11, 2024
@njzjz njzjz added this pull request to the merge queue Jul 11, 2024
Merged via the queue into deepmodeling:devel with commit 698ff6f Jul 11, 2024
60 checks passed
@njzjz njzjz deleted the entry-point-pt branch July 11, 2024 21:52
mtaillefumier pushed a commit to mtaillefumier/deepmd-kit that referenced this pull request Sep 18, 2024
Currently, we have it for TF, for the backend, but not for PT.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Documentation**
- Updated guidelines for packaging new codes into a Python package for
DeePMD-kit, including changes to use `pyproject.toml` instead of
`setup.py`.

- **Refactor**
- Improved entry point loading by centralizing the logic into a new
utility function, enhancing code maintainability and readability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants