Skip to content

Commit 64e163c

Browse files
authored
Accept multi-token interchange launch commands (#3543)
1 parent 1652304 commit 64e163c

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

parsl/executors/high_throughput/executor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"--mpi-launcher={mpi_launcher} "
5757
"--available-accelerators {accelerators}")
5858

59-
DEFAULT_INTERCHANGE_LAUNCH_CMD = "interchange.py"
59+
DEFAULT_INTERCHANGE_LAUNCH_CMD = ["interchange.py"]
6060

6161
GENERAL_HTEX_PARAM_DOCS = """provider : :class:`~parsl.providers.base.ExecutionProvider`
6262
Provider to access computation resources. Can be one of :class:`~parsl.providers.aws.aws.EC2Provider`,
@@ -78,9 +78,9 @@
7878
cores_per_worker, nodes_per_block, heartbeat_period ,heartbeat_threshold, logdir). For example:
7979
launch_cmd="process_worker_pool.py {debug} -c {cores_per_worker} --task_url={task_url} --result_url={result_url}"
8080
81-
interchange_launch_cmd : str
82-
Custom command line string to launch the interchange process from the executor. If undefined,
83-
the executor will use the default "interchange.py" command.
81+
interchange_launch_cmd : Sequence[str]
82+
Custom sequence of command line tokens to launch the interchange process from the executor. If
83+
undefined, the executor will use the default "interchange.py" command.
8484
8585
address : string
8686
An address to connect to the main Parsl process which is reachable from the network in which
@@ -238,7 +238,7 @@ def __init__(self,
238238
label: str = 'HighThroughputExecutor',
239239
provider: ExecutionProvider = LocalProvider(),
240240
launch_cmd: Optional[str] = None,
241-
interchange_launch_cmd: Optional[str] = None,
241+
interchange_launch_cmd: Optional[Sequence[str]] = None,
242242
address: Optional[str] = None,
243243
worker_ports: Optional[Tuple[int, int]] = None,
244244
worker_port_range: Optional[Tuple[int, int]] = (54000, 55000),
@@ -548,7 +548,7 @@ def _start_local_interchange_process(self) -> None:
548548

549549
config_pickle = pickle.dumps(interchange_config)
550550

551-
self.interchange_proc = subprocess.Popen(self.interchange_launch_cmd.encode("utf-8"), stdin=subprocess.PIPE)
551+
self.interchange_proc = subprocess.Popen(self.interchange_launch_cmd, stdin=subprocess.PIPE)
552552
stdin = self.interchange_proc.stdin
553553
assert stdin is not None, "Popen should have created an IO object (vs default None) because of PIPE mode"
554554

parsl/tests/test_htex/test_htex.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pathlib
2-
import warnings
32
from subprocess import Popen, TimeoutExpired
3+
from typing import Optional, Sequence
44
from unittest import mock
55

66
import pytest
@@ -139,13 +139,22 @@ def test_max_workers_per_node():
139139

140140

141141
@pytest.mark.local
142-
def test_htex_launch_cmd():
143-
htex = HighThroughputExecutor()
144-
assert htex.launch_cmd.startswith("process_worker_pool.py")
145-
assert htex.interchange_launch_cmd == "interchange.py"
146-
147-
launch_cmd = "custom-launch-cmd"
148-
ix_launch_cmd = "custom-ix-launch-cmd"
149-
htex = HighThroughputExecutor(launch_cmd=launch_cmd, interchange_launch_cmd=ix_launch_cmd)
150-
assert htex.launch_cmd == launch_cmd
151-
assert htex.interchange_launch_cmd == ix_launch_cmd
142+
@pytest.mark.parametrize("cmd", (None, "custom-launch-cmd"))
143+
def test_htex_worker_pool_launch_cmd(cmd: Optional[str]):
144+
if cmd:
145+
htex = HighThroughputExecutor(launch_cmd=cmd)
146+
assert htex.launch_cmd == cmd
147+
else:
148+
htex = HighThroughputExecutor()
149+
assert htex.launch_cmd.startswith("process_worker_pool.py")
150+
151+
152+
@pytest.mark.local
153+
@pytest.mark.parametrize("cmd", (None, ["custom", "launch", "cmd"]))
154+
def test_htex_interchange_launch_cmd(cmd: Optional[Sequence[str]]):
155+
if cmd:
156+
htex = HighThroughputExecutor(interchange_launch_cmd=cmd)
157+
assert htex.interchange_launch_cmd == cmd
158+
else:
159+
htex = HighThroughputExecutor()
160+
assert htex.interchange_launch_cmd == ["interchange.py"]

0 commit comments

Comments
 (0)