Skip to content

Fix EB4 related warning for hooks #1089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions eb_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from easybuild.tools.run import run_cmd
from easybuild.tools.systemtools import AARCH64, POWER, X86_64, get_cpu_architecture, get_cpu_features
from easybuild.tools.toolchain.compiler import OPTARCH_GENERIC
from easybuild.tools.version import VERSION as EASYBUILD_VERSION

# prefer importing LooseVersion from easybuild.tools, but fall back to distuils in case EasyBuild <= 4.7.0 is used
try:
Expand Down Expand Up @@ -126,9 +127,15 @@ 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' easyconfig parameter is set via EasyBlock.set_parallel in ready step based on available cores.
# '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']
parallel = self.cfg[parallel_param]
if parallel == 1:
return # no need to limit if already using 1 core

Expand All @@ -152,7 +159,7 @@ def post_ready_hook(self, *args, **kwargs):

# apply the limit if it's different from current
if new_parallel != parallel:
self.cfg['parallel'] = new_parallel
self.cfg[parallel_param] = 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)

Expand Down