diff --git a/src/ert/__init__.py b/src/ert/__init__.py index 71291d57050..7b2ca46c6cb 100644 --- a/src/ert/__init__.py +++ b/src/ert/__init__.py @@ -7,18 +7,18 @@ from .config import ( ErtScript, + ForwardModelStepDocumentation, ForwardModelStepJSON, ForwardModelStepPlugin, ForwardModelStepValidationError, ForwardModelStepWarning, - ForwardModelStepDocumentation, ) from .data import MeasuredData from .libres_facade import LibresFacade -from .simulator import BatchSimulator, BatchContext, JobStatus -from .workflow_runner import WorkflowRunner from .plugins import plugin from .scheduler import JobState +from .simulator import BatchContext, BatchSimulator, JobStatus +from .workflow_runner import WorkflowRunner __all__ = [ "BatchContext", diff --git a/src/ert/resources/__init__.py b/src/ert/resources/__init__.py new file mode 100644 index 00000000000..e087ebd6824 --- /dev/null +++ b/src/ert/resources/__init__.py @@ -0,0 +1,10 @@ +import os +import pathlib + +all_shell_script_fm_steps = [ + x.split(".py")[0] + for x in os.listdir(pathlib.Path(__file__).resolve().parent / "shell_scripts") + if not x.startswith("__") +] + +__all__ = ["all_shell_script_fm_steps"] diff --git a/src/everest/bin/utils.py b/src/everest/bin/utils.py index bdce715a78e..c02034fc634 100644 --- a/src/everest/bin/utils.py +++ b/src/everest/bin/utils.py @@ -9,6 +9,7 @@ import colorama from colorama import Fore +from ert.resources import all_shell_script_fm_steps from ert.simulator.batch_simulator_context import Status from everest.config import EverestConfig from everest.detached import ( @@ -20,7 +21,6 @@ start_monitor, ) from everest.export import export -from everest.jobs import shell_commands from everest.simulator import JOB_FAILURE, JOB_RUNNING, JOB_SUCCESS from everest.strings import EVEREST @@ -269,7 +269,11 @@ def _get_jobs_status(progress): def _filter_jobs(self, progress): if not self._show_all_jobs: progress = [ - [job for job in progress_list if job["name"] not in shell_commands] + [ + job + for job in progress_list + if job["name"] not in all_shell_script_fm_steps + ] for progress_list in progress ] return progress diff --git a/src/everest/jobs/__init__.py b/src/everest/jobs/__init__.py index df475dafb94..4097323e3f4 100644 --- a/src/everest/jobs/__init__.py +++ b/src/everest/jobs/__init__.py @@ -50,17 +50,3 @@ def fetch_script(script_name): _inject_scripts() - -# Note: Must be kept in sync with shell scripts on ERT-side -# (which is also not expected to change frequently/drastically) -shell_commands = ( - "careful_copy_file", - "copy_directory", - "copy_file", - "delete_directory", - "delete_file", - "make_directory", - "make_symlink", - "move_file", - "symlink", -) diff --git a/src/everest/suite.py b/src/everest/suite.py index e320af75760..7e3a72460b9 100644 --- a/src/everest/suite.py +++ b/src/everest/suite.py @@ -18,7 +18,7 @@ from ropt.plan import OptimizationPlanRunner from seba_sqlite import SqliteStorage -import everest +from ert.resources import all_shell_script_fm_steps from everest.config import EverestConfig from everest.optimizer.everest2ropt import everest2ropt from everest.plugins.site_config_env import PluginSiteConfigEnv @@ -217,7 +217,7 @@ def extract(path_str, key): for fms in progress_queue.steps: if ( not self._display_all_jobs - and fms.name in everest.jobs.shell_commands + and fms.name in all_shell_script_fm_steps ): continue realization = extract(fms.std_out_file, "geo_realization") diff --git a/tests/everest/entry_points/test_everest_entry.py b/tests/everest/entry_points/test_everest_entry.py index 472b8ea8066..b1606af6aed 100644 --- a/tests/everest/entry_points/test_everest_entry.py +++ b/tests/everest/entry_points/test_everest_entry.py @@ -5,6 +5,7 @@ import pytest +from ert.resources import all_shell_script_fm_steps from everest.bin.everest_script import everest_entry from everest.bin.kill_script import kill_entry from everest.bin.monitor_script import monitor_entry @@ -15,7 +16,6 @@ everserver_status, update_everserver_status, ) -from everest.jobs import shell_commands from everest.simulator import JOB_SUCCESS from ieverest.bin.ieverest_script import ieverest_entry from tests.everest.utils import capture_streams @@ -43,7 +43,7 @@ def build_job( "simulation": 0, } - shell_cmd_jobs = [build_job(name=command) for command in shell_commands] + shell_cmd_jobs = [build_job(name=command) for command in all_shell_script_fm_steps] all_jobs = [ *shell_cmd_jobs, build_job(name="make_pancakes"), @@ -315,7 +315,7 @@ def test_everest_entry_show_all_jobs( # of forward model jobs with capture_streams() as (out, _): everest_entry([CONFIG_FILE_MINIMAL, "--show-all-jobs"]) - for cmd in shell_commands: + for cmd in all_shell_script_fm_steps: assert cmd in out.getvalue() @@ -350,7 +350,7 @@ def test_everest_entry_no_show_all_jobs( # in the list of forward model jobs with capture_streams() as (out, _): everest_entry([CONFIG_FILE_MINIMAL]) - for cmd in shell_commands: + for cmd in all_shell_script_fm_steps: assert cmd not in out.getvalue() # Check the other jobs are still there @@ -386,7 +386,7 @@ def test_monitor_entry_show_all_jobs( with capture_streams() as (out, _): monitor_entry([CONFIG_FILE_MINIMAL, "--show-all-jobs"]) - for cmd in shell_commands: + for cmd in all_shell_script_fm_steps: assert cmd in out.getvalue() @@ -417,7 +417,7 @@ def test_monitor_entry_no_show_all_jobs( # in the list of forward model jobs with capture_streams() as (out, _): monitor_entry([CONFIG_FILE_MINIMAL]) - for cmd in shell_commands: + for cmd in all_shell_script_fm_steps: assert cmd not in out.getvalue() # Check the other jobs are still there diff --git a/tests/everest/test_shell_scripts.py b/tests/everest/test_shell_scripts.py index 251e44fac0a..e6b2ead21f0 100644 --- a/tests/everest/test_shell_scripts.py +++ b/tests/everest/test_shell_scripts.py @@ -1,5 +1,5 @@ +from ert.resources import all_shell_script_fm_steps from everest.config.everest_config import EverestConfig, get_system_installed_jobs -from everest.jobs import shell_commands from tests.everest.utils import relpath @@ -7,7 +7,7 @@ def test_everest_shell_commands_list(): # Check list of defined shell commands are part of the list of ert # installed system jobs system_installed_jobs = get_system_installed_jobs() - for command_name in shell_commands: + for command_name in all_shell_script_fm_steps: assert command_name in system_installed_jobs