Skip to content

Commit

Permalink
Support forwarding multiple arguments to reservoir simulators
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Jan 15, 2025
1 parent 56b3381 commit 9a4f5c8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ert/resources/forward_models/run_reservoirsimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def __init__(
self.summary_conversion: bool = summary_conversion

self.bypass_flowrun: bool = False
self.forwarded_args: list[str] = forwarded_args or []
self.forwarded_args: list[str] = " ".join(forwarded_args or []).split()

runner_abspath: str | Path | None = None
if simulator in {"eclipse", "e300"}:
Expand Down
32 changes: 31 additions & 1 deletion tests/ert/unit_tests/resources/test_run_reservoirsimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def slow_smry_writer():

@pytest.mark.parametrize("simulator", ["eclipse", "e300", "flow"])
@pytest.mark.usefixtures("use_tmpdir")
def test_runner_will_forward_unknown_arguments_to_eclrun(monkeypatch, simulator):
def test_runner_will_forward_unknown_arguments(monkeypatch, simulator):
eclrun_bin = Path("bin/eclrun")
eclrun_bin.parent.mkdir()
eclrun_bin.write_text("#!/bin/sh\necho $@ > eclrun_args\nexit 0", encoding="utf-8")
Expand All @@ -184,3 +184,33 @@ def test_runner_will_forward_unknown_arguments_to_eclrun(monkeypatch, simulator)
assert "--arbitrary_option_being_forwarded" in Path("eclrun_args").read_text(
encoding="utf-8"
)


@pytest.mark.parametrize("simulator", ["eclipse", "e300", "flow"])
@pytest.mark.usefixtures("use_tmpdir")
def test_runner_will_forward_multiple_unknown_arguments(monkeypatch, simulator):
eclrun_bin = Path("bin/eclrun")
eclrun_bin.parent.mkdir()
eclrun_bin.write_text(
'#!/bin/sh\nfor arg in "$@"; do echo $arg >> eclrun_args; done\nexit 0',
encoding="utf-8",
)
eclrun_bin.chmod(eclrun_bin.stat().st_mode | stat.S_IEXEC)
shutil.copy(eclrun_bin, "bin/flowrun")
monkeypatch.setenv("PATH", f"bin:{os.environ['PATH']}")
Path("EIGHTCELLS.DATA").touch()
Path("EIGHTCELLS.PRT").write_text("Errors 0\nBugs 0", encoding="utf-8")

run_reservoirsimulator.run_reservoirsimulator(
[
simulator,
"EIGHTCELLS.DATA",
"--version",
"2019.3",
"--first-option --second-option",
]
)

assert "--first-option\n--second-option" in Path("eclrun_args").read_text(
encoding="utf-8"
)

0 comments on commit 9a4f5c8

Please sign in to comment.