diff --git a/src/ert/plugins/hook_specifications/__init__.py b/src/ert/plugins/hook_specifications/__init__.py index dd497a281cb..7b8cedc57ae 100644 --- a/src/ert/plugins/hook_specifications/__init__.py +++ b/src/ert/plugins/hook_specifications/__init__.py @@ -1,3 +1,4 @@ +from .activate_script import activate_script from .ecl_config import ( ecl100_config_path, ecl300_config_path, @@ -18,9 +19,9 @@ add_span_processor, ) from .site_config import site_config_lines -from .activate_script import activate_script __all__ = [ + "activate_script", "add_log_handle_to_root", "add_span_processor", "ecl100_config_path", diff --git a/src/ert/plugins/plugin_manager.py b/src/ert/plugins/plugin_manager.py index 214e26a0016..a4e93007d16 100644 --- a/src/ert/plugins/plugin_manager.py +++ b/src/ert/plugins/plugin_manager.py @@ -158,7 +158,7 @@ def _site_config_lines(self) -> List[str]: def activate_script(self) -> str: def activate_script(): - shell = os.environ['SHELL'] + shell = os.environ["SHELL"] venv = os.environ.get("VIRTUAL_ENV") if not venv: return "" diff --git a/src/ert/scheduler/driver.py b/src/ert/scheduler/driver.py index 6de71fbfa27..227d146bef8 100644 --- a/src/ert/scheduler/driver.py +++ b/src/ert/scheduler/driver.py @@ -2,15 +2,14 @@ import asyncio import logging -import os import shlex from abc import ABC, abstractmethod from pathlib import Path from tempfile import NamedTemporaryFile from typing import Dict, Iterable, List, Optional, Tuple -from .event import Event from ..plugins import ErtPluginManager +from .event import Event SIGNAL_OFFSET = 128 """Bash and other shells add an offset of 128 to the signal value when a process exited due to a signal""" @@ -19,12 +18,12 @@ def create_submit_script(runpath: Path, executable: str, args: tuple[str, ...]) -> str: activate_script = ErtPluginManager().activate_script() with NamedTemporaryFile( - dir=runpath, - prefix=".compute_activate", - suffix=".sh", - mode="w", - encoding="utf-8", - delete=False, + dir=runpath, + prefix=".compute_activate", + suffix=".sh", + mode="w", + encoding="utf-8", + delete=False, ) as script_handle: script_handle.write(activate_script) return ( diff --git a/tests/ert/unit_tests/plugins/test_plugin_manager.py b/tests/ert/unit_tests/plugins/test_plugin_manager.py index 239b39dc1ed..161d7300161 100644 --- a/tests/ert/unit_tests/plugins/test_plugin_manager.py +++ b/tests/ert/unit_tests/plugins/test_plugin_manager.py @@ -142,7 +142,13 @@ def test_that_forward_model_step_is_registered(tmpdir): @pytest.mark.parametrize("venv", ["my_env", None]) -@pytest.mark.parametrize("shell, expected", [["csh", "#!csh\nsource my_env/bin/activate.csh"], ["bash", "#!bash\nsource my_env/bin/activate"]]) +@pytest.mark.parametrize( + "shell, expected", + [ + ["csh", "#!csh\nsource my_env/bin/activate.csh"], + ["bash", "#!bash\nsource my_env/bin/activate"], + ], +) def test_activate_script_generation(shell, expected, monkeypatch, venv): monkeypatch.setenv("SHELL", shell) pm = ErtPluginManager(plugins=[]) @@ -151,4 +157,4 @@ def test_activate_script_generation(shell, expected, monkeypatch, venv): assert pm.activate_script() == expected else: monkeypatch.delenv("VIRTUAL_ENV") - assert pm.activate_script() == "" + assert not pm.activate_script()