Skip to content

Commit d79ffe0

Browse files
committed
Fix errors due to parallel property being unset
Move `set_parallel` to `post_init` which matches better than the `ready_step`. That is described: > creating build dir, resetting environment > Verify if all is ok to start build. None of that matches the behavior of a `set_parallel` call as opposed to > Run post-initialization tasks. When handling potentially additional limitations in extensions we need to check if we have `parallel` set already before applying it. This should only be the case for tests which take shortcuts in the logic such as skipping `post_init`.
1 parent 48ea737 commit d79ffe0

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

easybuild/framework/easyblock.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ def post_init(self):
340340
# but needs to be correct if the build is performed in the installation directory
341341
self.log.info("Changing build dir to %s", self.installdir)
342342
self.builddir = self.installdir
343+
self.set_parallel()
343344

344345
# INIT/CLOSE LOG
345346
def _init_log(self):
@@ -2470,8 +2471,6 @@ def check_readiness_step(self):
24702471
"""
24712472
Verify if all is ok to start build.
24722473
"""
2473-
self.set_parallel()
2474-
24752474
# check whether modules are loaded
24762475
loadedmods = self.modules_tool.loaded_modules()
24772476
if len(loadedmods) > 0:

easybuild/framework/easyconfig/easyconfig.py

+5
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,11 @@ def all_dependencies(self):
12581258

12591259
return self._all_dependencies
12601260

1261+
@property
1262+
def is_parallel_set(self):
1263+
"""Return if the desired parallelism has been determined yet"""
1264+
return self._parallel is not None
1265+
12611266
@property
12621267
def parallel(self):
12631268
"""Number of parallel jobs to be used for building etc."""

easybuild/framework/extension.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,11 @@ def __init__(self, mself, ext, extra_params=None):
153153
self.log.debug("Skipping unknown custom easyconfig parameter '%s' for extension %s/%s: %s",
154154
key, name, version, value)
155155

156-
# Take potentially new value into account
157-
max_par = self.cfg['max_parallel']
158-
if max_par is not None and max_par < self.cfg.parallel:
159-
self.cfg.parallel = max_par
156+
# If parallelism has been set already take potentially new limitation into account
157+
if self.cfg.is_parallel_set:
158+
max_par = self.cfg['max_parallel']
159+
if max_par is not None and max_par < self.cfg.parallel:
160+
self.cfg.parallel = max_par
160161

161162
self.sanity_check_fail_msgs = []
162163
self.sanity_check_module_loaded = False

test/framework/easyblock.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2535,7 +2535,7 @@ def test_parallel(self):
25352535
self.writeEC()
25362536
with self.temporarily_allow_deprecated_behaviour(), self.mocked_stdout_stderr():
25372537
test_eb = EasyBlock(EasyConfig(self.eb_file))
2538-
test_eb.check_readiness_step()
2538+
test_eb.post_init()
25392539
self.assertEqual(test_eb.cfg.parallel, expected)
25402540
with self.temporarily_allow_deprecated_behaviour(), self.mocked_stdout_stderr():
25412541
self.assertEqual(test_eb.cfg['parallel'], expected)
@@ -2568,7 +2568,7 @@ def test_parallel(self):
25682568
self.writeEC()
25692569
with self.temporarily_allow_deprecated_behaviour(), self.mocked_stdout_stderr():
25702570
test_eb = EasyBlock(EasyConfig(self.eb_file))
2571-
test_eb.check_readiness_step()
2571+
test_eb.post_init()
25722572
self.assertEqual(test_eb.cfg.parallel, expected)
25732573
with self.temporarily_allow_deprecated_behaviour(), self.mocked_stdout_stderr():
25742574
self.assertEqual(test_eb.cfg['parallel'], expected)
@@ -2577,7 +2577,7 @@ def test_parallel(self):
25772577
self.contents = toytxt + '\nmaxparallel=2'
25782578
self.writeEC()
25792579
test_eb = EasyBlock(EasyConfig(self.eb_file))
2580-
test_eb.check_readiness_step()
2580+
test_eb.post_init()
25812581

25822582
test_eb.cfg['buildopts'] = '-j %(parallel)s'
25832583
self.assertEqual(test_eb.cfg['buildopts'], '-j 2')
@@ -2598,7 +2598,7 @@ def test_parallel(self):
25982598
test_eb = EasyBlock(EasyConfig(self.eb_file))
25992599
parallel = buildopt_parallel - 2
26002600
test_eb.cfg['parallel'] = parallel # Old Easyblocks might change that before the ready step
2601-
test_eb.check_readiness_step()
2601+
test_eb.post_init()
26022602
self.assertEqual(test_eb.cfg.parallel, parallel)
26032603
self.assertEqual(test_eb.cfg['parallel'], parallel)
26042604
# Afterwards it also gets reflected directly ignoring maxparallel

0 commit comments

Comments
 (0)