diff --git a/docs/ert/getting_started/howto/plugin_system.rst b/docs/ert/getting_started/howto/plugin_system.rst index 2a24fb5c7e3..6eae66c8bed 100644 --- a/docs/ert/getting_started/howto/plugin_system.rst +++ b/docs/ert/getting_started/howto/plugin_system.rst @@ -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 @@ -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" } @@ -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" ) @@ -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", @@ -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