Skip to content

Commit 5b6af40

Browse files
committed
Merge branch 'main' into sahil/strm-out-expl
2 parents eaa1b90 + cb0d510 commit 5b6af40

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

ipyparallel/apps/launcher.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import copy
66
import logging
77
import os
8-
import pipes
8+
import shlex
99
import stat
1010
import sys
1111
import time
@@ -633,7 +633,7 @@ def find_args(self):
633633
self.ssh_cmd
634634
+ self.ssh_args
635635
+ [self.location]
636-
+ list(map(pipes.quote, self.program + self.program_args))
636+
+ list(map(shlex.quote, self.program + self.program_args))
637637
)
638638

639639
def _send_file(self, local, remote):
@@ -1341,7 +1341,7 @@ class PBSControllerLauncher(PBSLauncher, BatchClusterAppMixin):
13411341
#PBS -N ipcontroller
13421342
%s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
13431343
"""
1344-
% (' '.join(map(pipes.quote, ipcontroller_cmd_argv)))
1344+
% (' '.join(map(shlex.quote, ipcontroller_cmd_argv)))
13451345
)
13461346

13471347
def start(self):
@@ -1361,7 +1361,7 @@ class PBSEngineSetLauncher(PBSLauncher, BatchClusterAppMixin):
13611361
#PBS -N ipengine
13621362
%s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
13631363
"""
1364-
% (' '.join(map(pipes.quote, ipengine_cmd_argv)))
1364+
% (' '.join(map(shlex.quote, ipengine_cmd_argv)))
13651365
)
13661366

13671367

@@ -1465,7 +1465,7 @@ class SlurmControllerLauncher(SlurmLauncher, BatchClusterAppMixin):
14651465
#SBATCH --ntasks=1
14661466
%s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
14671467
"""
1468-
% (' '.join(map(pipes.quote, ipcontroller_cmd_argv)))
1468+
% (' '.join(map(shlex.quote, ipcontroller_cmd_argv)))
14691469
)
14701470

14711471
def start(self):
@@ -1486,7 +1486,7 @@ class SlurmEngineSetLauncher(SlurmLauncher, BatchClusterAppMixin):
14861486
#SBATCH --job-name=ipy-engine-{cluster_id}
14871487
srun %s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
14881488
"""
1489-
% (' '.join(map(pipes.quote, ipengine_cmd_argv)))
1489+
% (' '.join(map(shlex.quote, ipengine_cmd_argv)))
14901490
)
14911491

14921492

@@ -1514,7 +1514,7 @@ class SGEControllerLauncher(SGELauncher, BatchClusterAppMixin):
15141514
#$ -N ipcontroller
15151515
%s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
15161516
"""
1517-
% (' '.join(map(pipes.quote, ipcontroller_cmd_argv)))
1517+
% (' '.join(map(shlex.quote, ipcontroller_cmd_argv)))
15181518
)
15191519

15201520
def start(self):
@@ -1534,7 +1534,7 @@ class SGEEngineSetLauncher(SGELauncher, BatchClusterAppMixin):
15341534
#$ -N ipengine
15351535
%s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
15361536
"""
1537-
% (' '.join(map(pipes.quote, ipengine_cmd_argv)))
1537+
% (' '.join(map(shlex.quote, ipengine_cmd_argv)))
15381538
)
15391539

15401540

@@ -1592,7 +1592,7 @@ class LSFControllerLauncher(LSFLauncher, BatchClusterAppMixin):
15921592
#BSUB -eo ipcontroller.e.%%J
15931593
%s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
15941594
"""
1595-
% (' '.join(map(pipes.quote, ipcontroller_cmd_argv)))
1595+
% (' '.join(map(shlex.quote, ipcontroller_cmd_argv)))
15961596
)
15971597

15981598
def start(self):
@@ -1612,7 +1612,7 @@ class LSFEngineSetLauncher(LSFLauncher, BatchClusterAppMixin):
16121612
#BSUB -eo ipengine.e.%%J
16131613
%s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
16141614
"""
1615-
% (' '.join(map(pipes.quote, ipengine_cmd_argv)))
1615+
% (' '.join(map(shlex.quote, ipengine_cmd_argv)))
16161616
)
16171617

16181618

ipyparallel/tests/test_client.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -615,26 +615,29 @@ def test_become_dask(self):
615615
def test_warning_on_hostname_match(self):
616616
location = socket.gethostname()
617617
with mock.patch('ipyparallel.client.client.is_local_ip', lambda x: False):
618-
with mock.patch('socket.gethostname', lambda: location[0:-1]), pytest.warns(
619-
RuntimeWarning
620-
): # should trigger warning
621-
c = self.connect_client()
618+
with mock.patch('socket.gethostname', lambda: location[0:-1]):
619+
with pytest.warns(RuntimeWarning): # should trigger warning
620+
c = self.connect_client()
621+
c.close()
622+
with mock.patch('socket.gethostname', lambda: location):
623+
with pytest.warns(None) as record: # should not trigger warning
624+
c = self.connect_client()
625+
# only capture runtime warnings
626+
runtime_warnings = [
627+
w for w in record if isinstance(w.message, RuntimeWarning)
628+
]
629+
assert len(runtime_warnings) == 0, str(
630+
[str(w) for w in runtime_warnings]
631+
)
622632
c.close()
623-
with mock.patch('socket.gethostname', lambda: location), pytest.warns(
624-
None
625-
) as record: # should not trigger warning
633+
634+
def test_local_ip_true_doesnt_trigger_warning(self):
635+
with mock.patch('ipyparallel.client.client.is_local_ip', lambda x: True):
636+
with pytest.warns(None) as record:
626637
c = self.connect_client()
627638
# only capture runtime warnings
628639
runtime_warnings = [
629640
w for w in record if isinstance(w.message, RuntimeWarning)
630641
]
631642
assert len(runtime_warnings) == 0, str([str(w) for w in runtime_warnings])
632643
c.close()
633-
634-
def test_local_ip_true_doesnt_trigger_warning(self):
635-
with mock.patch(
636-
'ipyparallel.client.client.is_local_ip', lambda x: True
637-
), pytest.warns(None) as record:
638-
c = self.connect_client()
639-
assert len(record) == 0, str([str(w) for w in record])
640-
c.close()

0 commit comments

Comments
 (0)