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

Fixup ert plugin documentation #9013

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 35 additions & 17 deletions docs/ert/getting_started/howto/plugin_system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,33 @@ Plugin system
Introduction
------------

Discovery is done by registering your plugin via a setuptools entry point, with the namespace :code:`ert`:
Assuming the following package structure::

your_package
├── pyproject.toml # or setup.py
└── src
└── your_module
├── __init__.py
├── your_plugins.py
└── ...

where the ert plugins are defined in :code:`your_plugins.py`, then discovery is done
by registering your plugin via a setuptools entry point, with the namespace :code:`ert`:

.. code-block:: python

setup(
...
entry_points={"ert": ["your_module_jobs = your_module.jobs"]},
...
)
# setup.py
setup(
...
entry_points={"ert": ["your_module_jobs = your_module.your_plugins"]},
...
)

.. code-block:: toml

# pyproject.toml
[project.entry-points.ert]
your_module_jobs = "your_module.your_plugins"

This entry point should point to the module where your ert plugin(s) exists.
(Notice that the entry point expects a list, so you can register multiple
Expand All @@ -32,12 +50,12 @@ use the simplified :code:`installable_jobs` function name, or

.. code-block:: python

import ert
import ert

@ert.plugin(name="my_plugin")
def installable_jobs() -> dict[str, str]:
return {
"job_name": "/path/to/workflow.config"
@ert.plugin(name="my_plugin")
def installable_jobs() -> dict[str, str]:
return {
"job_name": "/path/to/workflow.config"
}


Expand All @@ -50,8 +68,8 @@ use the simplified :code:`installable_jobs` function name, or

def validate_pre_realization_run(
self, fm_step_json: ert.ForwardModelStepJSON
) -> ForwardModelStepJSON:
if fm_json["argList"][0] not in ["start", "stop"]:
) -> ert.ForwardModelStepJSON:
if fm_step_json["argList"][0] not in ["start", "stop"]:
raise ert.ForwardModelStepValidationError(
"First argument to MY_FORWARD_MODEL must be either start or stop"
)
Expand All @@ -61,7 +79,7 @@ use the simplified :code:`installable_jobs` function name, or
pass

@staticmethod
def documentation() -> Optional[ert.ForwardModelStepDocumentation]:
def documentation() -> ert.ForwardModelStepDocumentation:
return ert.ForwardModelStepDocumentation(
category="utility.templating",
source_package="my_plugin",
Expand All @@ -70,9 +88,9 @@ use the simplified :code:`installable_jobs` function name, or
)


@ert.plugin(name="my_plugin")
def installable_forward_model_steps() -> list[ert.ForwardModelStepPlugin]:
return [MyForwardModel]
@ert.plugin(name="my_plugin")
def installable_forward_model_steps() -> list[ert.ForwardModelStepPlugin]:
return [MyForwardModel]


Notice that by using :code:`installable_forward_model_steps`, validation can be added
Expand Down