-
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.
* Sumo auth validation * update to latest version of ForwardModelStepPlugin * raise the proper exception instead of crashing ert * deprecate config file * add stderr and stdout file arguments --------- Co-authored-by: Runar Ask Johannessen <[email protected]>
- Loading branch information
1 parent
05e4fd2
commit 5b3c716
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