forked from deepmodeling/deepmd-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add plugin entry point for PT (deepmodeling#3965)
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>
- Loading branch information
Showing
6 changed files
with
60 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from deepmd.utils.entry_point import ( | ||
load_entry_point, | ||
) | ||
|
||
load_entry_point("deepmd.pt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from importlib import ( | ||
metadata, | ||
) | ||
|
||
|
||
def load_entry_point(group: str) -> list: | ||
"""Load entry points from a group. | ||
Parameters | ||
---------- | ||
group : str | ||
The group name. | ||
Returns | ||
------- | ||
list | ||
A list of loaded entry points. | ||
""" | ||
# https://setuptools.readthedocs.io/en/latest/userguide/entry_point.html | ||
try: | ||
eps = metadata.entry_points(group=group) | ||
except TypeError: | ||
eps = metadata.entry_points().get(group, []) | ||
return [ep.load() for ep in eps] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters