InVEST supports plugins at both the Python library level and the Workbench UI level.
Python Level
When natcap.invest is imported, it automatically searches for installed Python packages that follow the plugin pattern. A package is identified as a plugin if:
- Its package name begins with
invest. - It contains the required attributes (such as
MODEL_SPEC) described in the plugin developer's guide.
Once identified, these plugins are recorded in natcap.invest.models and are accessible via natcap.invest just like core models.
Workbench Level
In the InVEST Workbench, plugins are installed via the "Manage Plugins" window. Users can provide a Git URL or a local path. The installation process follows these steps:
- Download
pyproject.toml (if using a Git URL). - Parse metadata from
pyproject.toml. - Create a
micromamba environment containing python, git, and dependencies specified in tool.natcap.invest.conda_dependencies within the pyproject.toml. - Install the plugin into that environment using
pip. - Import the plugin and access metadata from
MODEL_SPEC. - Save the plugin information to the workbench settings store.
Note on Versioning: The Workbench identifies plugins using a hash of the model_id (from MODEL_SPEC) and the package.version (from pyproject.toml). This allows multiple versions of the same plugin to be installed simultaneously. However, at the Python level, only one plugin with the same package name can be active at a time.