Skip to content

Commit 9ba76dd

Browse files
authored
Merge pull request #3669 from Flamefire/allow_try_for_multi_tc
allow tweaking of easyconfigs from different toolchains
2 parents 850b7fd + 16a755b commit 9ba76dd

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

easybuild/framework/easyconfig/tweak.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,7 @@ def tweak(easyconfigs, build_specs, modtool, targetdirs=None):
9191
tweaked_ecs_path, tweaked_ecs_deps_path = None, None
9292
if targetdirs is not None:
9393
tweaked_ecs_path, tweaked_ecs_deps_path = targetdirs
94-
# make sure easyconfigs all feature the same toolchain (otherwise we *will* run into trouble)
95-
toolchains = nub(['%(name)s/%(version)s' % ec['ec']['toolchain'] for ec in easyconfigs])
96-
if len(toolchains) > 1:
97-
raise EasyBuildError("Multiple toolchains featured in easyconfigs, --try-X not supported in that case: %s",
98-
toolchains)
99-
# Toolchain is unique, let's store it
100-
source_toolchain = easyconfigs[-1]['ec']['toolchain']
10194
modifying_toolchains_or_deps = False
102-
target_toolchain = {}
10395
src_to_dst_tc_mapping = {}
10496
revert_to_regex = False
10597

@@ -117,6 +109,16 @@ def tweak(easyconfigs, build_specs, modtool, targetdirs=None):
117109
revert_to_regex = True
118110

119111
if not revert_to_regex:
112+
# make sure easyconfigs all feature the same toolchain (otherwise we *will* run into trouble)
113+
toolchains = nub(['%(name)s/%(version)s' % ec['ec']['toolchain'] for ec in easyconfigs])
114+
if len(toolchains) > 1:
115+
raise EasyBuildError("Multiple toolchains featured in easyconfigs, "
116+
"--try-X not supported in that case: %s",
117+
toolchains)
118+
# Toolchain is unique, let's store it
119+
source_toolchain = easyconfigs[-1]['ec']['toolchain']
120+
target_toolchain = {}
121+
120122
# we're doing something that involves the toolchain hierarchy;
121123
# obtain full dependency graph for specified easyconfigs;
122124
# easyconfigs will be ordered 'top-to-bottom' (toolchains and dependencies appearing first)

test/framework/easyconfig.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@
5757
from easybuild.framework.easyconfig.parser import EasyConfigParser, fetch_parameters_from_easyconfig
5858
from easybuild.framework.easyconfig.templates import template_constant_dict, to_template_str
5959
from easybuild.framework.easyconfig.style import check_easyconfigs_style
60-
from easybuild.framework.easyconfig.tools import categorize_files_by_type, check_sha256_checksums, dep_graph
61-
from easybuild.framework.easyconfig.tools import det_copy_ec_specs, find_related_easyconfigs, get_paths_for
60+
from easybuild.framework.easyconfig.tools import alt_easyconfig_paths, categorize_files_by_type, check_sha256_checksums
61+
from easybuild.framework.easyconfig.tools import dep_graph, det_copy_ec_specs, find_related_easyconfigs, get_paths_for
6262
from easybuild.framework.easyconfig.tools import parse_easyconfigs
63-
from easybuild.framework.easyconfig.tweak import obtain_ec_for, tweak_one
63+
from easybuild.framework.easyconfig.tweak import obtain_ec_for, tweak, tweak_one
6464
from easybuild.framework.extension import resolve_exts_filter_template
6565
from easybuild.toolchains.system import SystemToolchain
6666
from easybuild.tools.build_log import EasyBuildError
@@ -73,7 +73,7 @@
7373
from easybuild.tools.module_naming_scheme.utilities import det_full_ec_version
7474
from easybuild.tools.options import parse_external_modules_metadata
7575
from easybuild.tools.py2vs3 import OrderedDict, reload
76-
from easybuild.tools.robot import resolve_dependencies
76+
from easybuild.tools.robot import det_robot_path, resolve_dependencies
7777
from easybuild.tools.systemtools import AARCH64, KNOWN_ARCH_CONSTANTS, POWER, X86_64
7878
from easybuild.tools.systemtools import get_cpu_architecture, get_shared_lib_ext, get_os_name, get_os_version
7979

@@ -733,6 +733,38 @@ def test_tweaking(self):
733733
# cleanup
734734
os.remove(tweaked_fn)
735735

736+
def test_tweak_multiple_tcs(self):
737+
"""Test that tweaking variables of ECs from multiple toolchains works"""
738+
test_easyconfigs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
739+
740+
# Create directories to store the tweaked easyconfigs
741+
tweaked_ecs_paths, pr_path = alt_easyconfig_paths(self.test_prefix, tweaked_ecs=True)
742+
robot_path = det_robot_path([test_easyconfigs], tweaked_ecs_paths, pr_path, auto_robot=True)
743+
744+
init_config(build_options={
745+
'valid_module_classes': module_classes(),
746+
'robot_path': robot_path,
747+
'check_osdeps': False,
748+
})
749+
750+
# Allow tweaking of non-toolchain values for multiple ECs of different toolchains
751+
untweaked_openmpi_1 = os.path.join(test_easyconfigs, 'o', 'OpenMPI', 'OpenMPI-2.1.2-GCC-4.6.4.eb')
752+
untweaked_openmpi_2 = os.path.join(test_easyconfigs, 'o', 'OpenMPI', 'OpenMPI-3.1.1-GCC-7.3.0-2.30.eb')
753+
easyconfigs, _ = parse_easyconfigs([(untweaked_openmpi_1, False), (untweaked_openmpi_2, False)])
754+
tweak_specs = {'moduleclass': 'debugger'}
755+
easyconfigs = tweak(easyconfigs, tweak_specs, self.modtool, targetdirs=tweaked_ecs_paths)
756+
# Check that all expected tweaked easyconfigs exists
757+
tweaked_openmpi_1 = os.path.join(tweaked_ecs_paths[0], os.path.basename(untweaked_openmpi_1))
758+
tweaked_openmpi_2 = os.path.join(tweaked_ecs_paths[0], os.path.basename(untweaked_openmpi_2))
759+
self.assertTrue(os.path.isfile(tweaked_openmpi_1))
760+
self.assertTrue(os.path.isfile(tweaked_openmpi_2))
761+
tweaked_openmpi_content_1 = read_file(tweaked_openmpi_1)
762+
tweaked_openmpi_content_2 = read_file(tweaked_openmpi_2)
763+
self.assertTrue('moduleclass = "debugger"' in tweaked_openmpi_content_1,
764+
"Tweaked value not found in " + tweaked_openmpi_content_1)
765+
self.assertTrue('moduleclass = "debugger"' in tweaked_openmpi_content_2,
766+
"Tweaked value not found in " + tweaked_openmpi_content_2)
767+
736768
def test_installversion(self):
737769
"""Test generation of install version."""
738770

0 commit comments

Comments
 (0)