Skip to content

Add DP-GUI entry-points to DeepModeling packages #270

@njzjz

Description

@njzjz

Previously, DP-GUI was only hosted online, so the package input may not be the latest to match the stable or development version or another version that one may use. To resolve this issue, I made DP-GUI an independent Python library that can be served in the local environment. The Python package can read the arguments of the installed packages through entry points.

image

Here, when dpdispatcher is installed and has the dpgui entry points, DP-GUI can detect it.


Below are the required changes:

  1. Add the entry points to pyproject.toml:
[project.entry-points."dpgui"]
"DPDispatcher Machine" = "dpdispatcher.arginfo:machine_dargs"
"DPDispatcher Resources" = "dpdispatcher.arginfo:resources_dargs"
"DPDispatcher Task" = "dpdispatcher.arginfo:task_dargs"

The method is the same as that for the dargs Sphinx plugin, so no extra Python methods are required to add.

  1. Add a unit test:
import unittest

from dpgui import generate_dpgui_templates


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

This is a simple way to validate the entry points.

  1. add the scripts and arguments to start DP-GUI
def start_dpgui(*, port: int, bind_all: bool, **kwargs):
    try:
        from dpgui import start_dpgui
    except ModuleNotFoundError as e:
        raise ModuleNotFoundError("To use DP-GUI, please install the dpgui package:\npip install dpgui") from e
    start_dpgui(port=port, bind_all=bind_all)

Below is a checklist for DeepModeling packages that support DP-GUI:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions