-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validate eclrun-version with no eclconfig, untested
wip: simplified EclRun wip: can run eclipse on flow_example wip: eclipse maybe works, flowrun missing Renamed files, merging eclrun and flowrun now Merged runner script for flowrun and eclrun more opm flowrun tests in place Allow usage of direct flow installation if no flowrun No MPI run without flowrun fixup, test_await needs to u se tmp_dir fixture Can't test eclipse version when no elcrun. UNTESTED fixup d3ee82b127410fea173d7e914dd80dfb5132831e2 wip: dedicated test_run_reservoirsimultor
Showing
16 changed files
with
705 additions
and
1,667 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 was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
src/ert/resources/forward_models/res/script/ecl100_config.yml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/ert/resources/forward_models/res/script/ecl300_config.yml
This file was deleted.
Oops, something went wrong.
280 changes: 0 additions & 280 deletions
280
src/ert/resources/forward_models/res/script/ecl_config.py
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
417 changes: 417 additions & 0 deletions
417
src/ert/resources/forward_models/run_reservoirsimulator.py
Large diffs are not rendered by default.
Oops, something went wrong.
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
203 changes: 0 additions & 203 deletions
203
tests/ert/unit_tests/resources/test_ecl_versioning_config.py
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
255 changes: 93 additions & 162 deletions
255
...ests/resources/test_ecl_run_new_config.py → ...s/resources/test_run_eclipse_simulator.py
Large diffs are not rendered by default.
Oops, something went wrong.
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,72 @@ | ||
import shutil | ||
from pathlib import Path | ||
from subprocess import CalledProcessError | ||
|
||
import pytest | ||
|
||
from tests.ert.utils import SOURCE_DIR | ||
|
||
from ._import_from_location import import_from_location | ||
|
||
# import ecl_config.py and ecl_run from ert/forward-models package-data path | ||
# which. These are kept out of the ert package to avoid the overhead of | ||
# importing ert. This is necessary as these may be invoked as a subprocess on | ||
# each realization. | ||
|
||
run_reservoirsimulator = import_from_location( | ||
"run_reservoirsimulator", | ||
SOURCE_DIR / "src/ert/resources/forward_models/run_reservoirsimulator.py", | ||
) | ||
|
||
FLOW_VERSION = "daily" | ||
|
||
|
||
@pytest.mark.integration_test | ||
def test_flow_can_produce_output(source_root): | ||
shutil.copy(source_root / "test-data/ert/eclipse/SPE1.DATA", "SPE1.DATA") | ||
run_reservoirsimulator.RunReservoirSimulator( | ||
"flow", FLOW_VERSION, "SPE1.DATA" | ||
).runFlow() | ||
assert Path("SPE1.UNSMRY").exists() | ||
|
||
|
||
@pytest.mark.integration_test | ||
def test_flowrunner_will_raise_when_flow_fails(source_root): | ||
shutil.copy( | ||
source_root / "test-data/ert/eclipse/SPE1_ERROR.DATA", "SPE1_ERROR.DATA" | ||
) | ||
with pytest.raises(CalledProcessError, match="returned non-zero exit status 1"): | ||
run_reservoirsimulator.RunReservoirSimulator( | ||
"flow", FLOW_VERSION, "SPE1_ERROR.DATA" | ||
).runFlow() | ||
|
||
|
||
@pytest.mark.integration_test | ||
def test_flowrunner_will_can_ignore_flow_errors(source_root): | ||
shutil.copy( | ||
source_root / "test-data/ert/eclipse/SPE1_ERROR.DATA", "SPE1_ERROR.DATA" | ||
) | ||
run_reservoirsimulator.RunReservoirSimulator( | ||
"flow", FLOW_VERSION, "SPE1_ERROR.DATA", check_status=False | ||
).runFlow() | ||
|
||
|
||
@pytest.mark.integration_test | ||
def test_flowrunner_will_raise_on_unknown_version(): | ||
with pytest.raises(CalledProcessError): | ||
run_reservoirsimulator.RunReservoirSimulator( | ||
"flow", "garbled_version", "" | ||
).runFlow() | ||
|
||
|
||
@pytest.mark.integration_test | ||
def test_flow_with_parallel_keyword(source_root): | ||
"""This only tests that ERT will be able to start flow on a data deck with | ||
the PARALLEL keyword present. It does not assert anything regarding whether | ||
MPI-parallelization will get into play.""" | ||
shutil.copy( | ||
source_root / "test-data/ert/eclipse/SPE1_PARALLEL.DATA", "SPE1_PARALLEL.DATA" | ||
) | ||
run_reservoirsimulator.RunReservoirSimulator( | ||
"flow", FLOW_VERSION, "SPE1_PARALLEL.DATA" | ||
).runFlow() |
102 changes: 102 additions & 0 deletions
102
tests/ert/unit_tests/resources/test_run_reservoirsimulator.py
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,102 @@ | ||
import threading | ||
import time | ||
|
||
import numpy as np | ||
import pytest | ||
import resfo | ||
|
||
from tests.ert.utils import SOURCE_DIR | ||
|
||
from ._import_from_location import import_from_location | ||
|
||
# import ecl_config.py and ecl_run from ert/resources/forward_models | ||
# package-data path which. These are kept out of the ert package to avoid the | ||
# overhead of importing ert. This is necessary as these may be invoked as a | ||
# subprocess on each realization. | ||
|
||
|
||
run_reservoirsimulator = import_from_location( | ||
"run_reservoirsimulator", | ||
SOURCE_DIR / "src/ert/resources/forward_models/run_reservoirsimulator.py", | ||
) | ||
ecl_case_to_data_file = import_from_location( | ||
"ecl_case_to_data_file", | ||
SOURCE_DIR / "src/ert/resources/forward_models/run_reservoirsimulator.py", | ||
) | ||
|
||
|
||
def test_runners_are_found_from_path(): | ||
# assert different runners are looked for given wanted | ||
# simulator | ||
# assert runtimeoerror if no runner found | ||
pass | ||
|
||
|
||
def test_flowrun_can_be_bypassed(): | ||
# if flow is in path, then we can bypass | ||
# assert an error if num_cpu is more than 1., not suppported yet. | ||
pass | ||
|
||
|
||
def test_runner_fails_on_missing_data_file(): | ||
pass | ||
|
||
|
||
def test_ecl_case_from_data_file(): | ||
pass | ||
|
||
|
||
@pytest.mark.usefixtures("use_tmpdir") | ||
def test_await_completed_summary_file_will_timeout_on_missing_smry(): | ||
assert ( | ||
# Expected wait time is 0.3 | ||
run_reservoirsimulator.await_completed_unsmry_file( | ||
"SPE1.UNSMRY", max_wait=0.3, poll_interval=0.1 | ||
) | ||
> 0.3 | ||
) | ||
|
||
|
||
@pytest.mark.usefixtures("use_tmpdir") | ||
def test_await_completed_summary_file_will_return_asap(): | ||
resfo.write("FOO.UNSMRY", [("INTEHEAD", np.array([1], dtype=np.int32))]) | ||
assert ( | ||
0.01 | ||
# Expected wait time is the poll_interval | ||
< run_reservoirsimulator.await_completed_unsmry_file( | ||
"FOO.UNSMRY", max_wait=0.5, poll_interval=0.1 | ||
) | ||
< 0.4 | ||
) | ||
|
||
|
||
@pytest.mark.flaky(reruns=5) | ||
@pytest.mark.integration_test | ||
@pytest.mark.usefixtures("use_tmpdir") | ||
def test_await_completed_summary_file_will_wait_for_slow_smry(): | ||
# This is a timing test, and has inherent flakiness: | ||
# * Reading and writing to the same smry file at the same time | ||
# can make the reading throw an exception every time, and can | ||
# result in max_wait triggering. | ||
# * If the writer thread is starved, two consecutive polls may | ||
# yield the same summary length, resulting in premature exit. | ||
# * Heavily loaded hardware can make everything go too slow. | ||
def slow_smry_writer(): | ||
for size in range(10): | ||
resfo.write( | ||
"FOO.UNSMRY", (size + 1) * [("INTEHEAD", np.array([1], dtype=np.int32))] | ||
) | ||
time.sleep(0.05) | ||
|
||
thread = threading.Thread(target=slow_smry_writer) | ||
thread.start() | ||
time.sleep(0.1) # Let the thread start writing | ||
assert ( | ||
0.5 | ||
# Minimal wait time is around 0.55 | ||
< run_reservoirsimulator.await_completed_unsmry_file( | ||
"FOO.UNSMRY", max_wait=4, poll_interval=0.21 | ||
) | ||
< 2 | ||
) | ||
thread.join() |