Skip to content

Commit 76e5328

Browse files
authored
Remove script_dir state from channels (#3714)
This leaves channels as a stateless (and useless) object that can be removed in a subsequent PR. That removal will change/break a lot of config files so I want it to keep it separate from this attribute removal. # Changed Behaviour Batch providers will now use their own script_dir attribute, rather than the channel script_dir attribute. Prior to PR #3688 these attributes were paths on different file systems: the submit side (for providers) and the batch job execution side (for channels). PR #3688 removed support for batch job commands to run somewhere that isn't the workflow submit side, and so since then, these two attributes have been roughly equivalent. In some (obscure seeming cases) they might be different: if a channel is shared between DFKs, then the script_dir used by providers in one DFK will now no longer use the channel script dir set by the other DFK. This was probably a bug anyway but I am noting it because this PR isn't completely behaviour preserving. ## Type of change - Code maintenance/cleanup
1 parent a9a5b4b commit 76e5328

File tree

11 files changed

+11
-53
lines changed

11 files changed

+11
-53
lines changed

parsl/channels/base.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
1-
from abc import ABCMeta, abstractproperty
1+
from abc import ABCMeta
22

33

44
class Channel(metaclass=ABCMeta):
5-
@abstractproperty
6-
def script_dir(self) -> str:
7-
''' This is a property. Returns the directory assigned for storing all internal scripts such as
8-
scheduler submit scripts. This is usually where error logs from the scheduler would reside on the
9-
channel destination side.
10-
11-
Args:
12-
- None
13-
14-
Returns:
15-
- Channel script dir
16-
'''
17-
pass
18-
19-
# DFK expects to be able to modify this, so it needs to be in the abstract class
20-
@script_dir.setter
21-
def script_dir(self, value: str) -> None:
22-
pass
5+
pass

parsl/channels/local/local.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
import os
32

43
from parsl.channels.base import Channel
54
from parsl.utils import RepresentationMixin
@@ -8,24 +7,4 @@
87

98

109
class LocalChannel(Channel, RepresentationMixin):
11-
''' This is not even really a channel, since opening a local shell is not heavy
12-
and done so infrequently that they do not need a persistent channel
13-
'''
14-
15-
def __init__(self):
16-
''' Initialize the local channel. script_dir is required by set to a default.
17-
18-
KwArgs:
19-
- script_dir (string): Directory to place scripts
20-
'''
21-
self.script_dir = None
22-
23-
@property
24-
def script_dir(self):
25-
return self._script_dir
26-
27-
@script_dir.setter
28-
def script_dir(self, value):
29-
if value is not None:
30-
value = os.path.abspath(value)
31-
self._script_dir = value
10+
pass

parsl/dataflow/dflow.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,8 +1151,6 @@ def add_executors(self, executors: Sequence[ParslExecutor]) -> None:
11511151
executor.provider.script_dir = os.path.join(self.run_dir, 'submit_scripts')
11521152
os.makedirs(executor.provider.script_dir, exist_ok=True)
11531153

1154-
executor.provider.channel.script_dir = executor.provider.script_dir
1155-
11561154
self.executors[executor.label] = executor
11571155
executor.start()
11581156
block_executors = [e for e in executors if isinstance(e, BlockProviderExecutor)]

parsl/providers/condor/condor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def submit(self, command, tasks_per_node, job_name="parsl.condor"):
226226

227227
job_config = {}
228228
job_config["job_name"] = job_name
229-
job_config["submit_script_dir"] = self.channel.script_dir
229+
job_config["submit_script_dir"] = self.script_dir
230230
job_config["project"] = self.project
231231
job_config["nodes"] = self.nodes_per_block
232232
job_config["scheduler_options"] = scheduler_options

parsl/providers/grid_engine/grid_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def get_configs(self, command, tasks_per_node):
100100
self.nodes_per_block, tasks_per_node))
101101

102102
job_config = {}
103-
job_config["submit_script_dir"] = self.channel.script_dir
103+
job_config["submit_script_dir"] = self.script_dir
104104
job_config["nodes"] = self.nodes_per_block
105105
job_config["walltime"] = self.walltime
106106
job_config["scheduler_options"] = self.scheduler_options

parsl/providers/lsf/lsf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def submit(self, command, tasks_per_node, job_name="parsl.lsf"):
211211
logger.debug("Requesting one block with {} nodes".format(self.nodes_per_block))
212212

213213
job_config = {}
214-
job_config["submit_script_dir"] = self.channel.script_dir
214+
job_config["submit_script_dir"] = self.script_dir
215215
job_config["nodes"] = self.nodes_per_block
216216
job_config["tasks_per_node"] = tasks_per_node
217217
job_config["walltime"] = wtime_to_minutes(self.walltime)

parsl/providers/pbspro/pbspro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def submit(self, command, tasks_per_node, job_name="parsl"):
159159
)
160160

161161
job_config = {}
162-
job_config["submit_script_dir"] = self.channel.script_dir
162+
job_config["submit_script_dir"] = self.script_dir
163163
job_config["nodes_per_block"] = self.nodes_per_block
164164
job_config["ncpus"] = self.cpus_per_node
165165
job_config["walltime"] = self.walltime

parsl/providers/slurm/slurm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import re
55
import time
6-
from typing import Optional
6+
from typing import Any, Dict, Optional
77

88
import typeguard
99

@@ -286,8 +286,8 @@ def submit(self, command: str, tasks_per_node: int, job_name="parsl.slurm") -> s
286286

287287
logger.debug("Requesting one block with {} nodes".format(self.nodes_per_block))
288288

289-
job_config = {}
290-
job_config["submit_script_dir"] = self.channel.script_dir
289+
job_config: Dict[str, Any] = {}
290+
job_config["submit_script_dir"] = self.script_dir
291291
job_config["nodes"] = self.nodes_per_block
292292
job_config["tasks_per_node"] = tasks_per_node
293293
job_config["walltime"] = wtime_to_minutes(self.walltime)

parsl/providers/torque/torque.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def submit(self, command, tasks_per_node, job_name="parsl.torque"):
171171

172172
job_config = {}
173173
# TODO : script_path might need to change to accommodate script dir set via channels
174-
job_config["submit_script_dir"] = self.channel.script_dir
174+
job_config["submit_script_dir"] = self.script_dir
175175
job_config["nodes"] = self.nodes_per_block
176176
job_config["task_blocks"] = self.nodes_per_block * tasks_per_node
177177
job_config["nodes_per_block"] = self.nodes_per_block

parsl/tests/test_providers/test_pbspro_template.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def test_submit_script_basic(tmp_path):
1515
queue="debug", channel=LocalChannel()
1616
)
1717
provider.script_dir = tmp_path
18-
provider.channel.script_dir = tmp_path
1918
job_id = str(random.randint(55000, 59000))
2019
provider.execute_wait = mock.Mock(spec=PBSProProvider.execute_wait)
2120
provider.execute_wait.return_value = (0, job_id, "")

0 commit comments

Comments
 (0)