[InVEST Workbench 3.17.1 Plugin Error] Pydantic ValidationError when loading external plugin 'invest_sdr_usle_c_raster'

Dear NatCap Team/Community, I am encountering an issue when attempting to install/load an external InVEST plugin using the InVEST Workbench.

1. **InVEST Workbench Version:** 3.17.1 (installed on Windows)

2. **Plugin Name:** ‘invest_sdr_usle_c_raster’

3. **Operation:** Attempting to add the plugin via the Workbench interface. The process fails immediately with a `pydantic_core.ValidationError`. The error appears to be related to the plugin’s model specification metadata, specifically a required field is missing for an output raster definition. **Full Error Message:**

Error: Error invoking remote method ‘add-plugin’: Error: Command failed: “C:/Users/User/AppData/Local/Programs/InVEST 3.17.1 Workbench/resources/micromamba” run --prefix “C:/Users/User/AppData/Roaming/invest-workbench/micromamba_envs/plugin_1764392047618” python -c “import invest_sdr_usle_c_raster; print(invest_sdr_usle_c_raster.MODEL_SPEC.model_id)” Traceback (most recent call last): File “”, line 1, in import invest_sdr_usle_c_raster; print(invest_sdr_usle_c_raster.MODEL_SPEC.model_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “C:\Users\User\AppData\Roaming\invest-workbench\micromamba_envs\plugin_1764392047618\Lib\site-packages\invest_sdr_usle_c_raster_init_.py”, line 1, in from .invest_sdr_usle_c_raster import MODEL_SPEC File “C:\Users\User\AppData\Roaming\invest-workbench\micromamba_envs\plugin_1764392047618\Lib\site-packages\invest_sdr_usle_c_raster\invest_sdr_usle_c_raster.py”, line 170, in spec.SingleBandRasterOutput( ~~~~~~~~~~~~~~~~~~~~~~~~~~~^ id=“avoided_erosion.tif”, ^^^^^^^^^^^^^^^^^^^^^^^^^ …<5 lines>… units=u.metric_ton / u.hectare ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ), ^ File “C:\Users\User\AppData\Roaming\invest-workbench\micromamba_envs\plugin_1764392047618\Lib\site-packages\pydantic\main.py”, line 250, in init validated_self = self.pydantic_validator.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 1 validation error for SingleBandRasterOutput path Field required [type=missing, input_value={‘id’: ‘avoided_erosion.t…metric_ton / hectare’)>}, input_type=dict] For further information visit Redirecting...

Hi @wen0522, welcome to the forum and thanks for bringing this to our attention! We have recently been making changes to the MODEL_SPEC and this plugin appears not to have been updated accordingly. We will update the plugin and get back to you.

Thanks!

Hi @wen0522, we have updated the plugin and it should now be compatible with InVEST 3.17.1.

Thank you, the installation was successful. However, why does the plugin still require uploading the Land Use and Land Cover map? Isn’t the C-factor map already available?

This plugin in similar to the core InVEST SDR model, however instead of inputing C factor as a per-LULC class value, you can input it as a raster. However, LULC is not only used to map C values from the biophysical table, but also used to map P values in order to calculate C*P raster. Take a look at the source code and you’ll see the function _calculate_cp, which uses the LULC raster, LULC to P value dictionary mapped from the biophysical table, and the USLE raster.