Skip to content

Commit

Permalink
Merge branch 'main' into remove-md-log-file-option-for-rft
Browse files Browse the repository at this point in the history
  • Loading branch information
equinor-ruaj committed Nov 27, 2024
2 parents 6cb4661 + 5b3c716 commit 97c33e0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
File renamed without changes.
47 changes: 47 additions & 0 deletions src/fmu/sumo/sim2sumo/forward_models/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
"<S2S_CONF_PATH>",
"--env",
"<SUMO_ENV>",
],
default_mapping={
"<S2S_CONF_PATH>": "fmuconfig/output/global_variables.yml",
"<SUMO_ENV>": "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)
8 changes: 8 additions & 0 deletions src/fmu/sumo/sim2sumo/hook_implementations/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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]

0 comments on commit 97c33e0

Please sign in to comment.