-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move run_simulator function from test_check_swatinit_simulators
- Loading branch information
Showing
2 changed files
with
53 additions
and
30 deletions.
There are no files selected for viewing
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
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,50 @@ | ||
import subprocess | ||
import time | ||
from os import getcwd | ||
|
||
|
||
def run_simulator(simulator, data_file_path): | ||
"""Run the given simulator (Eclipse100 or OPM-flow) | ||
on a DATA file | ||
Will write to cwd. Caller is responsible for starting | ||
in a suitable directory. | ||
If the simulator fails, the stdout and stderr will be printed. | ||
Args: | ||
simulator (string): Path to a working reservoir simulator | ||
executable | ||
data_file_path (str): Location of DATA file | ||
Returns: | ||
None | ||
""" | ||
simulator_option = [] | ||
if "runeclipse" in simulator: | ||
simulator_option = ["-i"] | ||
if "flow" in simulator: | ||
simulator_option = ["--parsing-strictness=low"] | ||
|
||
result = subprocess.run( # pylint: disable=subprocess-run-check | ||
[simulator] + simulator_option + [data_file_path], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
|
||
if ( | ||
result.returncode != 0 | ||
and "runeclipse" in simulator | ||
and "LICENSE FAILURE" in result.stdout.decode() + result.stderr.decode() | ||
): | ||
print("Eclipse failed due to license server issues. Retrying in 30 seconds.") | ||
time.sleep(30) | ||
result = subprocess.run( # pylint: disable=subprocess-run-check | ||
[simulator] + simulator_option + [data_file_path], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
|
||
if result.returncode != 0: | ||
print(result.stdout.decode()) | ||
print(result.stderr.decode()) | ||
raise AssertionError(f"reservoir simulator failed in {getcwd()}") |