Skip to content

Commit 6683f5b

Browse files
authored
Remove Channel.execute_wait environment wait handling, part of #3515 (#3682)
Prior to this PR, Channel.execute_wait took a parameter to modify the unix environment of the newly executed process. This is unused in current Parsl. As part of the implementation of that, LocalChannel cached the unix environment at object initialization, and used that as the base to override with any supplied execute_wait environment parameter. Post this PR: The `env` parameter of execute_wait is removed. LocalChannel does not cache the environment any more. The executed process will inherit the parent process environment as of the point of execution not object initialization. # Changed Behaviour This is a behaviour change: if the workflow process changes its unix environment after creating the configuration objects, then prior to this PR, executed processes would not observe that change. Post this PR, executed processes will observe that change. I hope this is not a big deal. ## Type of change - Code maintenance/cleanup
1 parent 08aa003 commit 6683f5b

File tree

3 files changed

+4
-40
lines changed

3 files changed

+4
-40
lines changed

parsl/channels/base.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from abc import ABCMeta, abstractmethod, abstractproperty
2-
from typing import Dict, Tuple
2+
from typing import Tuple
33

44

55
class Channel(metaclass=ABCMeta):
@@ -22,16 +22,13 @@ class Channel(metaclass=ABCMeta):
2222
"""
2323

2424
@abstractmethod
25-
def execute_wait(self, cmd: str, walltime: int = 0, envs: Dict[str, str] = {}) -> Tuple[int, str, str]:
25+
def execute_wait(self, cmd: str, walltime: int = 0) -> Tuple[int, str, str]:
2626
''' Executes the cmd, with a defined walltime.
2727
2828
Args:
2929
- cmd (string): Command string to execute over the channel
3030
- walltime (int) : Timeout in seconds
3131
32-
KWargs:
33-
- envs (Dict[str, str]) : Environment variables to push to the remote side
34-
3532
Returns:
3633
- (exit_code, stdout, stderr) (int, string, string)
3734
'''

parsl/channels/local/local.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import copy
21
import logging
32
import os
43
import shutil
@@ -16,46 +15,33 @@ class LocalChannel(Channel, RepresentationMixin):
1615
and done so infrequently that they do not need a persistent channel
1716
'''
1817

19-
def __init__(self, envs={}, script_dir=None):
18+
def __init__(self, script_dir=None):
2019
''' Initialize the local channel. script_dir is required by set to a default.
2120
2221
KwArgs:
23-
- envs (dict) : A dictionary of env variables to be set when launching the shell
2422
- script_dir (string): Directory to place scripts
2523
'''
2624
self.hostname = "localhost"
27-
self.envs = envs
28-
local_env = os.environ.copy()
29-
self._envs = copy.deepcopy(local_env)
30-
self._envs.update(envs)
3125
self.script_dir = script_dir
3226

33-
def execute_wait(self, cmd, walltime=None, envs={}):
27+
def execute_wait(self, cmd, walltime=None):
3428
''' Synchronously execute a commandline string on the shell.
3529
3630
Args:
3731
- cmd (string) : Commandline string to execute
3832
- walltime (int) : walltime in seconds
3933
40-
Kwargs:
41-
- envs (dict) : Dictionary of env variables. This will be used
42-
to override the envs set at channel initialization.
43-
4434
Returns:
4535
- retcode : Return code from the execution
4636
- stdout : stdout string
4737
- stderr : stderr string
4838
'''
49-
current_env = copy.deepcopy(self._envs)
50-
current_env.update(envs)
51-
5239
try:
5340
logger.debug("Creating process with command '%s'", cmd)
5441
proc = subprocess.Popen(
5542
cmd,
5643
stdout=subprocess.PIPE,
5744
stderr=subprocess.PIPE,
58-
env=current_env,
5945
shell=True,
6046
preexec_fn=os.setpgrp
6147
)

parsl/tests/test_channels/test_local_channel.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,3 @@ def test_env():
1717

1818
x = [s for s in stdout if s.startswith("HOME=")]
1919
assert x, "HOME not found"
20-
21-
22-
@pytest.mark.local
23-
def test_env_mod():
24-
''' Testing for env update at execute time.
25-
'''
26-
27-
lc = LocalChannel()
28-
rc, stdout, stderr = lc.execute_wait("env", 1, {'TEST_ENV': 'fooo'})
29-
30-
stdout = stdout.split('\n')
31-
x = [s for s in stdout if s.startswith("PATH=")]
32-
assert x, "PATH not found"
33-
34-
x = [s for s in stdout if s.startswith("HOME=")]
35-
assert x, "HOME not found"
36-
37-
x = [s for s in stdout if s.startswith("TEST_ENV=fooo")]
38-
assert x, "User set env missing"

0 commit comments

Comments
 (0)