Skip to content

Commit

Permalink
dpgui
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed Oct 8, 2023
1 parent da100dc commit a217e59
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 1 deletion.
4 changes: 4 additions & 0 deletions backend/dynamic_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def dynamic_metadata(
"pytest",
"pytest-cov",
"pytest-sugar",
"dpgui",
],
"docs": [
"sphinx>=3.1.1",
Expand All @@ -62,6 +63,9 @@ def dynamic_metadata(
"i-PI",
*find_libpython_requires,
],
"gui": [
"dpgui",
],
**get_tf_requirement(tf_version),
"cu11": [
"nvidia-cuda-runtime-cu11",
Expand Down
4 changes: 4 additions & 0 deletions deepmd/entrypoints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from .freeze import (
freeze,
)
from .gui import (
start_dpgui,
)
from .neighbor_stat import (
neighbor_stat,
)
Expand All @@ -41,4 +44,5 @@
"make_model_devi",
"convert",
"neighbor_stat",
"start_dpgui",
]
26 changes: 26 additions & 0 deletions deepmd/entrypoints/gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
"""DP-GUI entrypoint."""


def start_dpgui(*, port: int, bind_all: bool, **kwargs):
"""Host DP-GUI server.
Parameters
----------
port : int
The port to serve DP-GUI on.
bind_all : bool
Serve on all public interfaces. This will expose your DP-GUI instance
to the network on both IPv4 and IPv6 (where available).
**kwargs
additional arguments
"""
try:
from dpgui import (

Check warning on line 19 in deepmd/entrypoints/gui.py

View check run for this annotation

Codecov / codecov/patch

deepmd/entrypoints/gui.py#L18-L19

Added lines #L18 - L19 were not covered by tests
start_dpgui,
)
except ModuleNotFoundError:
raise RuntimeError(

Check warning on line 23 in deepmd/entrypoints/gui.py

View check run for this annotation

Codecov / codecov/patch

deepmd/entrypoints/gui.py#L22-L23

Added lines #L22 - L23 were not covered by tests
"To use DP-GUI, please install the dpgui package:\npip install dpgui"
)
start_dpgui(port=port, bind_all=bind_all)

Check warning on line 26 in deepmd/entrypoints/gui.py

View check run for this annotation

Codecov / codecov/patch

deepmd/entrypoints/gui.py#L26

Added line #L26 was not covered by tests
3 changes: 3 additions & 0 deletions deepmd/entrypoints/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
freeze,
make_model_devi,
neighbor_stat,
start_dpgui,
test,
train_dp,
transfer,
Expand Down Expand Up @@ -89,6 +90,8 @@ def main(args: Optional[Union[List[str], argparse.Namespace]] = None):
neighbor_stat(**dict_args)
elif args.command == "train-nvnmd": # nvnmd
train_nvnmd(**dict_args)
elif args.command == "gui":
start_dpgui(**dict_args)

Check warning on line 94 in deepmd/entrypoints/main.py

View check run for this annotation

Codecov / codecov/patch

deepmd/entrypoints/main.py#L93-L94

Added lines #L93 - L94 were not covered by tests
elif args.command is None:
pass
else:
Expand Down
23 changes: 23 additions & 0 deletions deepmd_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,29 @@ def main_parser() -> argparse.ArgumentParser:
action="store_true",
help="Skip calculating neighbor statistics. Sel checking, automatic sel, and model compression will be disabled.",
)

# gui
parser_gui = subparsers.add_parser(
"gui",
parents=[parser_log],
help="Serve DP-GUI.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser_gui.add_argument(
"-p",
"--port",
type=int,
default=6042,
help="The port to serve DP-GUI on.",
)
parser_gui.add_argument(
"--bind_all",
action="store_true",
help=(
"Serve on all public interfaces. This will expose your DP-GUI instance "
"to the network on both IPv4 and IPv6 (where available)."
),
)
return parser


Expand Down
2 changes: 1 addition & 1 deletion doc/train/train-input.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Training Parameters
======================================
.. note::
One can load, modify, and export the input file by using our effective web-based tool `DP-GUI <https://deepmodeling.com/dpgui/input/deepmd-kit-2.0>`_. All training parameters below can be set in DP-GUI. By clicking "SAVE JSON", one can download the input file for furthur training.
One can load, modify, and export the input file by using our effective web-based tool `DP-GUI <https://deepmodeling.com/dpgui/input/deepmd-kit-2.0>`_ online or hosted using the command line interface :ref:`dp gui <Command line interface>`. All training parameters below can be set in DP-GUI. By clicking "SAVE JSON", one can download the input file for furthur training.

.. dargs::
:module: deepmd.utils.argcheck
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ keywords = ["deepmd"]
[project.entry-points."lammps.plugins"]
deepmd = "deepmd.lmp:get_op_dir"

[project.entry-points."dpgui"]
"DeePMD-kit" = "deepmd.utils.argcheck:gen_args"

[project.urls]
Homepage = "https://github.com/deepmodeling/deepmd-kit"
documentation = "https://docs.deepmodeling.com/projects/deepmd"
Expand Down
11 changes: 11 additions & 0 deletions source/tests/test_gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import unittest

from dpgui import (
generate_dpgui_templates,
)


class TestDPGUI(unittest.TestCase):
def test_dpgui_entrypoints(self):
self.assertTrue(len(generate_dpgui_templates()) > 0)

0 comments on commit a217e59

Please sign in to comment.