-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-docs-and-error-message
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters