Skip to content

Commit

Permalink
Rename job configuration files
Browse files Browse the repository at this point in the history
libres will look for an executable in the same folder as the job
configuration file is located. If the name of the config is the same as
the name of the executable, libres will be confused. The usual standard
in ERT would be to capitalize the config file. On OSX systems, which are
case-insensitive, this isn't viable. The job config files are therefore
appended with "_CONFIG". The jobs will be installed as JOB_NAME
JOB_NAME_CONFIG, and the JOB_NAME_CONFIG will point to an executable
named job_name - which we install with entry-points. The user can use
the forward model job as normal: SIMULATION_JOB JOB_NAME
  • Loading branch information
lars-petter-hauge committed Oct 5, 2021
1 parent 97d96b2 commit a631c7b
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 20 deletions.
19 changes: 18 additions & 1 deletion semeio/hook_implementations/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
from ert_shared.plugins.plugin_response import plugin_response


def _remove_suffix(string, suffix):
if not string.endswith(suffix):
raise ValueError(f"{string} does not end with {suffix}")
return string[: -len(suffix)]


def _get_jobs_from_directory(directory):
resource_directory = resource_filename("semeio", directory)

Expand All @@ -14,7 +20,18 @@ def _get_jobs_from_directory(directory):
for f in os.listdir(resource_directory)
if os.path.isfile(os.path.join(resource_directory, f))
]
return {os.path.basename(path): path for path in all_files}
# libres will look for an executable in the same folder as the job configuration
# file is located. If the name of the config is the same as the name of the executable,
# libres will be confused. The usual standard in ERT would be to capitalize the config
# file. On OSX systems, which are case-insensitive, this isn't viable. The job config
# files are therefore appended with "_CONFIG".
# The jobs will be installed as JOB_NAME JOB_NAME_CONFIG, and the JOB_NAME_CONFIG will
# point to an executable named job_name - which we install with entry-points. The user
# can use the forward model job as normal:
# SIMULATION_JOB JOB_NAME
return {
_remove_suffix(os.path.basename(path), "_CONFIG"): path for path in all_files
}


# pylint: disable=no-value-for-parameter
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions tests/hook_implementations/test_hook_implementations.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def test_hook_implementations():
)

expected_jobs = {
"DESIGN_KW": "semeio/jobs/config_jobs/DESIGN_KW",
"DESIGN2PARAMS": "semeio/jobs/config_jobs/DESIGN2PARAMS",
"STEA": "semeio/jobs/config_jobs/STEA",
"GENDATA_RFT": "semeio/jobs/config_jobs/GENDATA_RFT",
"PYSCAL": "semeio/jobs/config_jobs/PYSCAL",
"INSERT_NOSIM": "semeio/jobs/config_jobs/INSERT_NOSIM",
"REMOVE_NOSIM": "semeio/jobs/config_jobs/REMOVE_NOSIM",
"OTS": "semeio/jobs/config_jobs/OTS",
"DESIGN_KW": "semeio/jobs/config_jobs/DESIGN_KW_CONFIG",
"DESIGN2PARAMS": "semeio/jobs/config_jobs/DESIGN2PARAMS_CONFIG",
"STEA": "semeio/jobs/config_jobs/STEA_CONFIG",
"GENDATA_RFT": "semeio/jobs/config_jobs/GENDATA_RFT_CONFIG",
"PYSCAL": "semeio/jobs/config_jobs/PYSCAL_CONFIG",
"INSERT_NOSIM": "semeio/jobs/config_jobs/INSERT_NOSIM_CONFIG",
"REMOVE_NOSIM": "semeio/jobs/config_jobs/REMOVE_NOSIM_CONFIG",
"OTS": "semeio/jobs/config_jobs/OTS_CONFIG",
}
installable_jobs = pm.get_installable_jobs()
for wf_name, wf_location in expected_jobs.items():
Expand Down
8 changes: 7 additions & 1 deletion tests/jobs/nosim/test_nosim.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
import ert_shared.hook_implementations


@pytest.mark.skipif(sys.platform == "darwin", reason="Skip test for Mac OS")
@pytest.mark.skipif(
sys.platform == "darwin", reason="Skip test for Mac OS - invalid use of sed"
)
# The GNU extension for the sed command on osx behaves slightly different.
# The result when running the forward model job is as follow:
# cat insert_nosim.stderr.1
# sed: 1: "TEST.DATA": invalid command code T
@pytest.mark.parametrize(
"nosim_command,data_input,data_expected",
[
Expand Down
2 changes: 1 addition & 1 deletion tests/jobs/rft/test_gendata_rft.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def test_defaults():
import semeio.jobs

job_description_file = os.path.join(
os.path.dirname(semeio.jobs.__file__), "config_jobs", "GENDATA_RFT"
os.path.dirname(semeio.jobs.__file__), "config_jobs", "GENDATA_RFT_CONFIG"
)

# Crude parsing of the file
Expand Down
9 changes: 0 additions & 9 deletions tests/test_ert_integration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import subprocess
import pytest

Expand All @@ -21,14 +20,6 @@
"""


@pytest.mark.skipif(
sys.platform == "darwin",
reason=(
"Forward models have same name as executable and "
"libres will find wrong exe on case insensitive system "
"bug report here: https://github.com/equinor/libres/issues/1053"
),
)
@pytest.mark.parametrize(
"forward_model, configuration, expected_error",
[
Expand Down

0 comments on commit a631c7b

Please sign in to comment.