Remove os.getcwd from function signature#31480
Merged
alalazo merged 1 commit intospack:developfrom Jul 12, 2022
Merged
Conversation
fixes spack#29730 This is also wrong since it binds the directory at the time of module import, rather than the one at the time of function call.
Member
Author
|
Not sure it's worth a test, but in case this ought to be tested with an integration test, since the error happens at import time and |
Member
Author
|
For reference, here's what happens when trying to spawn a clean process to test this: tmpdir = local('/tmp/pytest-of-culpo/pytest-5/test_installing_when_cwd_does_0'), install_mockery = None, mock_fetch = None
mock_packages = <spack.repo.RepoPath object at 0x7f670d2dd8e0>
@pytest.mark.regression('29730')
def test_installing_when_cwd_does_not_exist(
tmpdir, install_mockery, mock_fetch, mock_packages
):
deleted_dir = tmpdir.ensure_dir('local')
# Execute with spawn to force a new import
ctx = multiprocessing.get_context('spawn')
p = ctx.Process(target=install, args=('trivial-install-test-package',))
with deleted_dir.as_cwd():
deleted_dir.remove(rec=1)
# Ensure this doesn't raise.
> p.start()
lib/spack/spack/test/cmd/install.py:1075:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/multiprocessing/process.py:121: in start
self._popen = self._Popen(self)
/usr/lib/python3.8/multiprocessing/context.py:284: in _Popen
return Popen(process_obj)
/usr/lib/python3.8/multiprocessing/popen_spawn_posix.py:32: in __init__
super().__init__(process_obj)
/usr/lib/python3.8/multiprocessing/popen_fork.py:19: in __init__
self._launch(process_obj)
/usr/lib/python3.8/multiprocessing/popen_spawn_posix.py:42: in _launch
prep_data = spawn.get_preparation_data(process_obj._name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
name = 'SpawnProcess-1'
def get_preparation_data(name):
'''
Return info about parent needed by child to unpickle process object
'''
_check_not_importing_main()
d = dict(
log_to_stderr=util._log_to_stderr,
authkey=process.current_process().authkey,
)
if util._logger is not None:
d['log_level'] = util._logger.getEffectiveLevel()
sys_path=sys.path.copy()
try:
i = sys_path.index('')
except ValueError:
pass
else:
sys_path[i] = process.ORIGINAL_DIR
d.update(
name=name,
sys_path=sys_path,
sys_argv=sys.argv,
orig_dir=process.ORIGINAL_DIR,
> dir=os.getcwd(),
start_method=get_start_method(),
)
E FileNotFoundError: [Errno 2] No such file or directory
/usr/lib/python3.8/multiprocessing/spawn.py:176: FileNotFoundError
==================================================================== slowest 30 durations ====================================================================
0.02s setup lib/spack/spack/test/cmd/install.py::test_installing_when_cwd_does_not_exist[mock_archive0]
0.02s call lib/spack/spack/test/cmd/install.py::test_installing_when_cwd_does_not_exist[mock_archive0]
(1 durations < 0.005s hidden. Use -vv to show these durations.)
================================================================== short test summary info ===================================================================
FAILED lib/spack/spack/test/cmd/install.py::test_installing_when_cwd_does_not_exist[mock_archive0] - FileNotFoundError: [Errno 2] No such file or directory
===================================================================== 1 failed in 0.25s ====================================================================== |
haampie
approved these changes
Jul 12, 2022
bhatiaharsh
pushed a commit
to bhatiaharsh/spack
that referenced
this pull request
Aug 8, 2022
fixes spack#29730 This is also wrong since it binds the directory at the time of module import, rather than the one at the time of function call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #29730
This is also wrong since it binds the directory at the time of module import, rather than the one at the time of function call.