Skip to content

molforge.plugins

plugins

Plugin registry and discovery.

Third-party packages can register additional engines, parsers, or scoring functions by exposing entry points under the molforge.plugins group:

.. code-block:: toml

[project.entry-points."molforge.plugins"]
my_docker = "my_pkg:register"

The function pointed to by the entry point should call :func:register_engine, :func:register_parser, or :func:register_scorer to make its capability available.

available

available(kind: str | None = None) -> list[str]

List registered plugin names, optionally filtered by kind.

clear

clear() -> None

Empty the registry. Primarily useful for tests.

discover

discover() -> list[str]

Discover and load plugins exposed via the molforge.plugins entry-point group.

Each entry point should be a callable taking no arguments; it is expected to perform its own registration via the register_* functions exported from this module.

Returns:

Type Description
list[str]

A list of entry-point names that were successfully loaded. If a

list[str]

plugin fails to import or its registration function raises, the

list[str]

exception is suppressed and the name is omitted from the

list[str]

returned list. (We deliberately don't propagate exceptions

list[str]

because one broken plugin shouldn't be able to break every

list[str]

downstream user of molforge.)

Example

A third-party plugin declared in its own pyproject.toml::

[project.entry-points."molforge.plugins"]
my_docker = "my_pkg.molforge_integration:register"

where my_pkg.molforge_integration:register is a callable that calls :func:register_engine (or :func:register_parser / :func:register_scorer) one or more times.

From a user's code::

from molforge.plugins import discover, get
loaded = discover()
# loaded == ["my_docker"]
engine = get("engine", "my_docker_engine")()

get

get(kind: str, name: str) -> Any

Return a registered factory, raising KeyError if absent.

register_engine

register_engine(
    name: str, factory: Callable[..., Any]
) -> None

Register a docking / folding / MD engine factory by name.

register_parser

register_parser(
    name: str, factory: Callable[..., Any]
) -> None

Register a file-format parser by name (typically the extension).

register_scorer

register_scorer(
    name: str, factory: Callable[..., Any]
) -> None

Register a scoring function by name.