Skip to content

Commit 7c2646e

Browse files
authored
Remove provider/channel push/pull of files (#3690)
This removes push/pull support from channels. All the HPC providers used channel.push_file to push their batch scripts to the (no-longer) remote system. This has been a basically dead code path since removal of non-remote channels: The channel is always a LocalChannel now (PR #3677) The "remote" script directory is always the local script directory (PR #3688) and so `LocalChannel.push_file` always skips making a copy and returns the path it was given without further action. So all the removed code is a no-op, and this PR simplifies that into nothing. # Changed Behaviour Some providers had an option to let users decide if scripts (and other files) would be pushed/pulled to the remote system. Those options are removed by this PR. ## Type of change - New feature - Code maintenance/cleanup
1 parent 1c3e509 commit 7c2646e

File tree

9 files changed

+11
-116
lines changed

9 files changed

+11
-116
lines changed

parsl/channels/base.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,3 @@ def script_dir(self) -> str:
5252
@script_dir.setter
5353
def script_dir(self, value: str) -> None:
5454
pass
55-
56-
@abstractmethod
57-
def push_file(self, source: str, dest_dir: str) -> str:
58-
''' Channel will take care of moving the file from source to the destination
59-
directory
60-
61-
Args:
62-
source (string) : Full filepath of the file to be moved
63-
dest_dir (string) : Absolute path of the directory to move to
64-
65-
Returns:
66-
destination_path (string)
67-
'''
68-
pass
69-
70-
@abstractmethod
71-
def pull_file(self, remote_source: str, local_dir: str) -> str:
72-
''' Transport file on the remote side to a local directory
73-
74-
Args:
75-
remote_source (string): remote_source
76-
local_dir (string): Local directory to copy to
77-
78-
79-
Returns:
80-
destination_path (string)
81-
'''
82-
pass

parsl/channels/local/local.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import logging
22
import os
3-
import shutil
43
import subprocess
54

65
from parsl.channels.base import Channel
7-
from parsl.channels.errors import FileCopyException
86
from parsl.utils import RepresentationMixin
97

108
logger = logging.getLogger(__name__)
@@ -57,40 +55,6 @@ def execute_wait(self, cmd, walltime=None):
5755

5856
return (retcode, stdout.decode("utf-8"), stderr.decode("utf-8"))
5957

60-
def push_file(self, source, dest_dir):
61-
''' If the source files dirpath is the same as dest_dir, a copy
62-
is not necessary, and nothing is done. Else a copy is made.
63-
64-
Args:
65-
- source (string) : Path to the source file
66-
- dest_dir (string) : Path to the directory to which the files is to be copied
67-
68-
Returns:
69-
- destination_path (String) : Absolute path of the destination file
70-
71-
Raises:
72-
- FileCopyException : If file copy failed.
73-
'''
74-
75-
local_dest = os.path.join(dest_dir, os.path.basename(source))
76-
77-
# Only attempt to copy if the target dir and source dir are different
78-
if os.path.dirname(source) != dest_dir:
79-
try:
80-
shutil.copyfile(source, local_dest)
81-
os.chmod(local_dest, 0o700)
82-
83-
except OSError as e:
84-
raise FileCopyException(e, "localhost")
85-
86-
else:
87-
os.chmod(local_dest, 0o700)
88-
89-
return local_dest
90-
91-
def pull_file(self, remote_source, local_dir):
92-
return self.push_file(remote_source, local_dir)
93-
9458
@property
9559
def script_dir(self):
9660
return self._script_dir

parsl/providers/condor/condor.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,14 @@ def submit(self, command, tasks_per_node, job_name="parsl.condor"):
245245
with open(userscript_path, 'w') as f:
246246
f.write(job_config["worker_init"] + '\n' + wrapped_command)
247247

248-
user_script_path = self.channel.push_file(userscript_path, self.channel.script_dir)
249-
the_input_files = [user_script_path] + self.transfer_input_files
248+
the_input_files = [userscript_path] + self.transfer_input_files
250249
job_config["input_files"] = ','.join(the_input_files)
251-
job_config["job_script"] = os.path.basename(user_script_path)
250+
job_config["job_script"] = os.path.basename(userscript_path)
252251

253252
# Construct and move the submit script
254253
self._write_submit_script(template_string, script_path, job_name, job_config)
255-
channel_script_path = self.channel.push_file(script_path, self.channel.script_dir)
256254

257-
cmd = "condor_submit {0}".format(channel_script_path)
255+
cmd = "condor_submit {0}".format(script_path)
258256
try:
259257
retcode, stdout, stderr = self.execute_wait(cmd)
260258
except Exception as e:

parsl/providers/grid_engine/grid_engine.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,10 @@ def submit(self, command, tasks_per_node, job_name="parsl.sge"):
142142
logger.debug("Writing submit script")
143143
self._write_submit_script(template_string, script_path, job_name, job_config)
144144

145-
channel_script_path = self.channel.push_file(script_path, self.channel.script_dir)
146145
if self.queue is not None:
147-
cmd = "qsub -q {0} -terse {1}".format(self.queue, channel_script_path)
146+
cmd = "qsub -q {0} -terse {1}".format(self.queue, script_path)
148147
else:
149-
cmd = "qsub -terse {0}".format(channel_script_path)
148+
cmd = "qsub -terse {0}".format(script_path)
150149
retcode, stdout, stderr = self.execute_wait(cmd)
151150

152151
if retcode == 0:

parsl/providers/local/local.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ class LocalProvider(ExecutionProvider, RepresentationMixin):
3232
Ratio of provisioned task slots to active tasks. A parallelism value of 1 represents aggressive
3333
scaling where as many resources as possible are used; parallelism close to 0 represents
3434
the opposite situation in which as few resources as possible (i.e., min_blocks) are used.
35-
move_files : Optional[Bool]
36-
Should files be moved? By default, Parsl will try to figure this out itself (= None).
37-
If True, then will always move. If False, will never move.
3835
worker_init : str
3936
Command to be run before starting a worker, such as 'module load Anaconda; source activate env'.
4037
"""
@@ -48,8 +45,7 @@ def __init__(self,
4845
max_blocks=1,
4946
worker_init='',
5047
cmd_timeout=30,
51-
parallelism=1,
52-
move_files=None):
48+
parallelism=1):
5349
self.channel = channel
5450
self._label = 'local'
5551
self.nodes_per_block = nodes_per_block
@@ -61,7 +57,6 @@ def __init__(self,
6157
self.parallelism = parallelism
6258
self.script_dir = None
6359
self.cmd_timeout = cmd_timeout
64-
self.move_files = move_files
6560

6661
# Dictionary that keeps track of jobs, keyed on job_id
6762
self.resources = {}
@@ -83,7 +78,6 @@ def status(self, job_ids):
8378
if job_dict['status'] and job_dict['status'].terminal:
8479
# We already checked this and it can't change after that
8580
continue
86-
# Script path should point to remote path if _should_move_files() is True
8781
script_path = job_dict['script_path']
8882

8983
alive = self._is_alive(job_dict)
@@ -137,8 +131,6 @@ def _is_alive(self, job_dict):
137131

138132
def _job_file_path(self, script_path: str, suffix: str) -> str:
139133
path = '{0}{1}'.format(script_path, suffix)
140-
if self._should_move_files():
141-
path = self.channel.pull_file(path, self.script_dir)
142134
return path
143135

144136
def _read_job_file(self, script_path: str, suffix: str) -> str:
@@ -216,9 +208,6 @@ def submit(self, command, tasks_per_node, job_name="parsl.localprovider"):
216208

217209
job_id = None
218210
remote_pid = None
219-
if self._should_move_files():
220-
logger.debug("Pushing start script")
221-
script_path = self.channel.push_file(script_path, self.channel.script_dir)
222211

223212
logger.debug("Launching")
224213
# We need to capture the exit code and the streams, so we put them in files. We also write
@@ -254,9 +243,6 @@ def submit(self, command, tasks_per_node, job_name="parsl.localprovider"):
254243

255244
return job_id
256245

257-
def _should_move_files(self):
258-
return (self.move_files is None and not isinstance(self.channel, LocalChannel)) or (self.move_files)
259-
260246
def cancel(self, job_ids):
261247
''' Cancels the jobs specified by a list of job ids
262248

parsl/providers/lsf/lsf.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class LSFProvider(ClusterProvider, RepresentationMixin):
6868
:class:`~parsl.launchers.SingleNodeLauncher` (the default),
6969
:class:`~parsl.launchers.SrunLauncher`, or
7070
:class:`~parsl.launchers.AprunLauncher`
71-
move_files : Optional[Bool]: should files be moved? by default, Parsl will try to move files.
7271
bsub_redirection: Bool
7372
Should a redirection symbol "<" be included when submitting jobs, i.e., Bsub < job_script.
7473
request_by_nodes: Bool
@@ -92,7 +91,6 @@ def __init__(self,
9291
project=None,
9392
queue=None,
9493
cmd_timeout=120,
95-
move_files=True,
9694
bsub_redirection=False,
9795
request_by_nodes=True,
9896
launcher=SingleNodeLauncher()):
@@ -112,7 +110,6 @@ def __init__(self,
112110
self.queue = queue
113111
self.cores_per_block = cores_per_block
114112
self.cores_per_node = cores_per_node
115-
self.move_files = move_files
116113
self.bsub_redirection = bsub_redirection
117114
self.request_by_nodes = request_by_nodes
118115

@@ -230,17 +227,10 @@ def submit(self, command, tasks_per_node, job_name="parsl.lsf"):
230227
logger.debug("Writing submit script")
231228
self._write_submit_script(template_string, script_path, job_name, job_config)
232229

233-
if self.move_files:
234-
logger.debug("moving files")
235-
channel_script_path = self.channel.push_file(script_path, self.channel.script_dir)
236-
else:
237-
logger.debug("not moving files")
238-
channel_script_path = script_path
239-
240230
if self.bsub_redirection:
241-
cmd = "bsub < {0}".format(channel_script_path)
231+
cmd = "bsub < {0}".format(script_path)
242232
else:
243-
cmd = "bsub {0}".format(channel_script_path)
233+
cmd = "bsub {0}".format(script_path)
244234
retcode, stdout, stderr = super().execute_wait(cmd)
245235

246236
job_id = None

parsl/providers/pbspro/pbspro.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,13 @@ def submit(self, command, tasks_per_node, job_name="parsl"):
183183
logger.debug("Writing submit script")
184184
self._write_submit_script(self.template_string, script_path, job_name, job_config)
185185

186-
channel_script_path = self.channel.push_file(script_path, self.channel.script_dir)
187-
188186
submit_options = ''
189187
if self.queue is not None:
190188
submit_options = '{0} -q {1}'.format(submit_options, self.queue)
191189
if self.account is not None:
192190
submit_options = '{0} -A {1}'.format(submit_options, self.account)
193191

194-
launch_cmd = "qsub {0} {1}".format(submit_options, channel_script_path)
192+
launch_cmd = "qsub {0} {1}".format(submit_options, script_path)
195193
retcode, stdout, stderr = self.execute_wait(launch_cmd)
196194

197195
job_id = None

parsl/providers/slurm/slurm.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ class SlurmProvider(ClusterProvider, RepresentationMixin):
110110
:class:`~parsl.launchers.SingleNodeLauncher` (the default),
111111
:class:`~parsl.launchers.SrunLauncher`, or
112112
:class:`~parsl.launchers.AprunLauncher`
113-
move_files : Optional[Bool]: should files be moved? by default, Parsl will try to move files.
114113
"""
115114

116115
@typeguard.typechecked
@@ -134,7 +133,6 @@ def __init__(self,
134133
worker_init: str = '',
135134
cmd_timeout: int = 10,
136135
exclusive: bool = True,
137-
move_files: bool = True,
138136
launcher: Launcher = SingleNodeLauncher()):
139137
label = 'slurm'
140138
super().__init__(label,
@@ -152,7 +150,6 @@ def __init__(self,
152150
self.cores_per_node = cores_per_node
153151
self.mem_per_node = mem_per_node
154152
self.exclusive = exclusive
155-
self.move_files = move_files
156153
self.account = account
157154
self.qos = qos
158155
self.constraint = constraint
@@ -308,14 +305,7 @@ def submit(self, command: str, tasks_per_node: int, job_name="parsl.slurm") -> s
308305
logger.debug("Writing submit script")
309306
self._write_submit_script(template_string, script_path, job_name, job_config)
310307

311-
if self.move_files:
312-
logger.debug("moving files")
313-
channel_script_path = self.channel.push_file(script_path, self.channel.script_dir)
314-
else:
315-
logger.debug("not moving files")
316-
channel_script_path = script_path
317-
318-
retcode, stdout, stderr = self.execute_wait("sbatch {0}".format(channel_script_path))
308+
retcode, stdout, stderr = self.execute_wait("sbatch {0}".format(script_path))
319309

320310
if retcode == 0:
321311
for line in stdout.split('\n'):

parsl/providers/torque/torque.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,13 @@ def submit(self, command, tasks_per_node, job_name="parsl.torque"):
189189
logger.debug("Writing submit script")
190190
self._write_submit_script(self.template_string, script_path, job_name, job_config)
191191

192-
channel_script_path = self.channel.push_file(script_path, self.channel.script_dir)
193-
194192
submit_options = ''
195193
if self.queue is not None:
196194
submit_options = '{0} -q {1}'.format(submit_options, self.queue)
197195
if self.account is not None:
198196
submit_options = '{0} -A {1}'.format(submit_options, self.account)
199197

200-
launch_cmd = "qsub {0} {1}".format(submit_options, channel_script_path)
198+
launch_cmd = "qsub {0} {1}".format(submit_options, script_path)
201199
retcode, stdout, stderr = self.execute_wait(launch_cmd)
202200

203201
job_id = None

0 commit comments

Comments
 (0)