diff --git a/src/fmu/sumo/sim2sumo/config_jobs/SIM2SUMO b/src/fmu/sumo/sim2sumo/config_jobs/SIM2SUMO_CONFIG_DEPRECATED similarity index 100% rename from src/fmu/sumo/sim2sumo/config_jobs/SIM2SUMO rename to src/fmu/sumo/sim2sumo/config_jobs/SIM2SUMO_CONFIG_DEPRECATED diff --git a/src/fmu/sumo/sim2sumo/forward_models/__init__.py b/src/fmu/sumo/sim2sumo/forward_models/__init__.py new file mode 100644 index 00000000..4808c230 --- /dev/null +++ b/src/fmu/sumo/sim2sumo/forward_models/__init__.py @@ -0,0 +1,47 @@ +import subprocess +from ert import ( + ForwardModelStepJSON, + ForwardModelStepPlugin, + ForwardModelStepValidationError, +) + + +class Sim2Sumo(ForwardModelStepPlugin): + def __init__(self): + super().__init__( + name="SIM2SUMO", + command=[ + "sim2sumo", + "--config_path", + "", + "--env", + "", + ], + default_mapping={ + "": "fmuconfig/output/global_variables.yml", + "": "prod", + }, + stderr_file="sim2sumo.stderr", + stdout_file="sim2sumo.stdout", + ) + + def validate_pre_realization_run( + self, fm_step_json: ForwardModelStepJSON + ) -> ForwardModelStepJSON: + return fm_step_json + + def validate_pre_experiment( + self, fm_step_json: ForwardModelStepJSON + ) -> None: + env = fm_step_json["argList"][3] + command = f"sumo_login -e {env} -m silent" + return_code = subprocess.call(command, shell=True) + + err_msg = ( + "Your config uses Sumo" + ", please authenticate using:" + f"sumo_login{f' -e {env}' if env != 'prod' else ''}" + ) + + if return_code != 0: + raise ForwardModelStepValidationError(err_msg) diff --git a/src/fmu/sumo/sim2sumo/hook_implementations/jobs.py b/src/fmu/sumo/sim2sumo/hook_implementations/jobs.py index fd5dd819..05fb68af 100644 --- a/src/fmu/sumo/sim2sumo/hook_implementations/jobs.py +++ b/src/fmu/sumo/sim2sumo/hook_implementations/jobs.py @@ -7,6 +7,8 @@ from ert.shared.plugins.plugin_manager import hook_implementation from ert.shared.plugins.plugin_response import plugin_response +from fmu.sumo.sim2sumo.forward_models import Sim2Sumo + DESCRIPTION = """ Makes result simulator (Eclipse, OPM, IX) available in sumo. This is done by SIM2SUMO in a three step process: @@ -98,3 +100,9 @@ def job_documentation(job_name): "examples": EXAMPLES, "category": "export", } + + +@hook_implementation +@plugin_response(plugin_name="fmu_sumo_uploader") +def installable_forward_model_steps(): + return [Sim2Sumo]