diff --git a/eb_hooks.py b/eb_hooks.py index f65c3ec7..25b55b81 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -128,15 +128,10 @@ def post_ready_hook(self, *args, **kwargs): Post-ready hook: limit parallellism for selected builds based on software name and CPU target. parallelism needs to be limited because some builds require a lot of memory per used core. """ - # 'parallel' (EB4) or 'max_parallel' (EB5) easyconfig parameter is set via EasyBlock.set_parallel in ready step - # based on available cores. - - # Check whether we have EasyBuild 4 or 5 - parallel_param = 'parallel' - if EASYBUILD_VERSION >= '5': - parallel_param = 'max_parallel' - # get current parallelism setting - parallel = self.cfg[parallel_param] + # 'parallel' easyconfig parameter (EB4) or the parallel property (EB5) is set via EasyBlock.set_parallel + # in ready step based on available cores + parallel = getattr(self, 'parallel', self.cfg['parallel']) + if parallel == 1: return # no need to limit if already using 1 core @@ -167,7 +162,10 @@ def post_ready_hook(self, *args, **kwargs): # apply the limit if it's different from current if new_parallel != parallel: - self.cfg[parallel_param] = new_parallel + if EASYBUILD_VERSION >= '5': + self.cfg.parallel = new_parallel + else: + self.cfg['parallel'] = new_parallel msg = "limiting parallelism to %s (was %s) for %s on %s to avoid out-of-memory failures during building/testing" print_msg(msg % (new_parallel, parallel, self.name, cpu_target), log=self.log)