From 3cbdc7ded9dcdef13a21a2f5237d291d61cb5860 Mon Sep 17 00:00:00 2001 From: Jonathan Karlsen Date: Wed, 18 Sep 2024 13:05:18 +0200 Subject: [PATCH] Add ForwardModelStepWarning class --- docs/getting_started/howto/plugin_system.rst | 3 ++- src/ert/__init__.py | 2 ++ src/ert/config/__init__.py | 2 ++ src/ert/config/forward_model_step.py | 5 +++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/getting_started/howto/plugin_system.rst b/docs/getting_started/howto/plugin_system.rst index 329edfd281c..d2d7ad95321 100644 --- a/docs/getting_started/howto/plugin_system.rst +++ b/docs/getting_started/howto/plugin_system.rst @@ -79,7 +79,8 @@ Notice that by using :code:`installable_forward_model_steps`, validation can be where the methods ``validate_pre_experiment`` or ``validate_pre_realization_run`` can throw ``ForwardModelStepValidationError`` to indicate that the configuration of the forward model step is invalid (which ert then handles gracefully and presents nicely -to the user). +to the user). If you want to show a warning in cases where the configuration cannot be +validated pre-experiment, you can use the ``ForwardModelStepWarning.warn(...)`` method. To provide documentation for a forward model step given with ``installable_jobs``, use the :code:`job_documentation` name. If you are the diff --git a/src/ert/__init__.py b/src/ert/__init__.py index 192e0e4a68b..71291d57050 100644 --- a/src/ert/__init__.py +++ b/src/ert/__init__.py @@ -10,6 +10,7 @@ ForwardModelStepJSON, ForwardModelStepPlugin, ForwardModelStepValidationError, + ForwardModelStepWarning, ForwardModelStepDocumentation, ) from .data import MeasuredData @@ -27,6 +28,7 @@ "ForwardModelStepJSON", "ForwardModelStepPlugin", "ForwardModelStepValidationError", + "ForwardModelStepWarning", "JobState", "JobStatus", "LibresFacade", diff --git a/src/ert/config/__init__.py b/src/ert/config/__init__.py index f4585bee2a0..f20c2a6ce6b 100644 --- a/src/ert/config/__init__.py +++ b/src/ert/config/__init__.py @@ -14,6 +14,7 @@ ForwardModelStepJSON, ForwardModelStepPlugin, ForwardModelStepValidationError, + ForwardModelStepWarning, ) from .gen_data_config import GenDataConfig from .gen_kw_config import GenKwConfig, PriorDict, TransformFunction @@ -62,6 +63,7 @@ "ForwardModelStepJSON", "ForwardModelStepPlugin", "ForwardModelStepValidationError", + "ForwardModelStepWarning", "GenDataConfig", "GenKwConfig", "HookRuntime", diff --git a/src/ert/config/forward_model_step.py b/src/ert/config/forward_model_step.py index 093f3920946..a52c5ec0ab5 100644 --- a/src/ert/config/forward_model_step.py +++ b/src/ert/config/forward_model_step.py @@ -12,6 +12,7 @@ from typing_extensions import NotRequired, Unpack +from ert.config.parsing.config_errors import ConfigWarning from ert.substitution_list import SubstitutionList from .parsing import ( @@ -29,6 +30,10 @@ class ForwardModelStepValidationError(Exception): """ +class ForwardModelStepWarning(ConfigWarning): + pass + + class ForwardModelStepJSON(TypedDict): """ A dictionary containing information about how a forward model step should be run