diff --git a/smartsim/_core/commands/command.py b/smartsim/_core/commands/command.py index 0769d342e..3e47a0c40 100644 --- a/smartsim/_core/commands/command.py +++ b/smartsim/_core/commands/command.py @@ -60,7 +60,9 @@ def __getitem__(self, idx: t.Union[int, slice]) -> t.Union[str, Self]: def __setitem__(self, idx: int, value: str) -> None: ... @t.overload def __setitem__(self, idx: slice, value: t.Iterable[str]) -> None: ... - def __setitem__(self, idx: t.Union[int, slice], value: t.Union[str, t.Iterable[str]]) -> None: + def __setitem__( + self, idx: t.Union[int, slice], value: t.Union[str, t.Iterable[str]] + ) -> None: """Set the command at the specified index.""" if isinstance(idx, int): if not isinstance(value, str): diff --git a/smartsim/_core/commands/commandList.py b/smartsim/_core/commands/commandList.py index 92d4dd8df..a6018aa24 100644 --- a/smartsim/_core/commands/commandList.py +++ b/smartsim/_core/commands/commandList.py @@ -51,7 +51,9 @@ def commands(self) -> t.List[Command]: def __getitem__(self, idx: int) -> Command: ... @t.overload def __getitem__(self, idx: slice) -> t.List[Command]: ... - def __getitem__(self, idx: t.Union[slice, int]) -> t.Union[Command, t.List[Command]]: + def __getitem__( + self, idx: t.Union[slice, int] + ) -> t.Union[Command, t.List[Command]]: """Get the Command at the specified index.""" return self._commands[idx] diff --git a/smartsim/_core/dispatch.py b/smartsim/_core/dispatch.py index 029d22506..f16d3f294 100644 --- a/smartsim/_core/dispatch.py +++ b/smartsim/_core/dispatch.py @@ -29,7 +29,6 @@ import dataclasses import os import pathlib - import typing as t from typing_extensions import Self, TypeAlias, TypeVarTuple, Unpack diff --git a/smartsim/_core/shell/shellLauncher.py b/smartsim/_core/shell/shellLauncher.py index a3270fc12..aaa864aaa 100644 --- a/smartsim/_core/shell/shellLauncher.py +++ b/smartsim/_core/shell/shellLauncher.py @@ -27,16 +27,19 @@ from __future__ import annotations -import subprocess as sp -import typing as t import io import pathlib import subprocess as sp +import typing as t import psutil -from smartsim._core.dispatch import _EnvironMappingType, _FormatterType, _WorkingDirectory from smartsim._core.arguments.shell import ShellLaunchArguments +from smartsim._core.dispatch import ( + _EnvironMappingType, + _FormatterType, + _WorkingDirectory, +) from smartsim._core.utils import helpers from smartsim._core.utils.launcher import ExecutableProtocol, create_job_id from smartsim.error import errors @@ -52,6 +55,7 @@ logger = get_logger(__name__) + class ShellLauncherCommand(t.NamedTuple): env: _EnvironMappingType path: pathlib.Path @@ -59,6 +63,7 @@ class ShellLauncherCommand(t.NamedTuple): stderr: io.TextIOWrapper | int command_tuple: tuple[str, tuple[str, ...]] | t.Sequence[str] + def make_shell_format_fn( run_command: str | None, ) -> _FormatterType[ShellLaunchArguments, ShellLauncherCommand]: diff --git a/smartsim/settings/arguments/launch/lsf.py b/smartsim/settings/arguments/launch/lsf.py index 52b4035b5..bc8571dcf 100644 --- a/smartsim/settings/arguments/launch/lsf.py +++ b/smartsim/settings/arguments/launch/lsf.py @@ -30,13 +30,10 @@ import subprocess import typing as t -from smartsim._core.dispatch import ( - _EnvironMappingType, - dispatch, -) +from smartsim._core.arguments.shell import ShellLaunchArguments +from smartsim._core.dispatch import _EnvironMappingType, dispatch from smartsim._core.shell.shellLauncher import ShellLauncher, ShellLauncherCommand from smartsim._core.utils.launcher import ExecutableProtocol -from smartsim._core.arguments.shell import ShellLaunchArguments from smartsim.log import get_logger from ...common import set_check_input diff --git a/smartsim/settings/arguments/launch/slurm.py b/smartsim/settings/arguments/launch/slurm.py index 6e8c2d130..b842a647c 100644 --- a/smartsim/settings/arguments/launch/slurm.py +++ b/smartsim/settings/arguments/launch/slurm.py @@ -32,15 +32,10 @@ import subprocess import typing as t -from smartsim._core.dispatch import ( - _EnvironMappingType, - dispatch, -) +from smartsim._core.arguments.shell import ShellLaunchArguments +from smartsim._core.dispatch import _EnvironMappingType, dispatch from smartsim._core.shell.shellLauncher import ShellLauncher, ShellLauncherCommand from smartsim._core.utils.launcher import ExecutableProtocol -from smartsim._core.arguments.shell import ShellLaunchArguments -from smartsim._core.dispatch import dispatch - from smartsim.log import get_logger from ...common import set_check_input diff --git a/tests/test_shell_launcher.py b/tests/test_shell_launcher.py index dbee64aa8..c1c447da7 100644 --- a/tests/test_shell_launcher.py +++ b/tests/test_shell_launcher.py @@ -125,7 +125,9 @@ def test_shell_launcher_start_calls_popen( shell_launcher, shell_cmd: ShellLauncherCommand ): """Test that the process leading up to the shell launcher popen call was correct""" - with unittest.mock.patch("smartsim._core.shell.shellLauncher.sp.Popen") as mock_open: + with unittest.mock.patch( + "smartsim._core.shell.shellLauncher.sp.Popen" + ) as mock_open: _ = shell_launcher.start(shell_cmd) mock_open.assert_called_once() @@ -134,7 +136,9 @@ def test_shell_launcher_start_calls_popen_with_value( shell_launcher, shell_cmd: ShellLauncherCommand ): """Test that popen was called with correct values""" - with unittest.mock.patch("smartsim._core.shell.shellLauncher.sp.Popen") as mock_open: + with unittest.mock.patch( + "smartsim._core.shell.shellLauncher.sp.Popen" + ) as mock_open: _ = shell_launcher.start(shell_cmd) mock_open.assert_called_once_with( shell_cmd.command_tuple,