From d61f33d20b7d9d6657b8f4bc45657d4a63a1c243 Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Tue, 10 Dec 2024 18:14:51 +0100 Subject: [PATCH 1/8] Initial attempt for an EasyBuild hook that makes modules print an LmodError when they are loaded --- eb_hooks.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/eb_hooks.py b/eb_hooks.py index 5bf42b6bbf..b445754d83 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -77,6 +77,10 @@ def parse_hook(ec, *args, **kwargs): if ec.name in PARSE_HOOKS: PARSE_HOOKS[ec.name](ec, eprefix) + # Always trigger this one, regardless of ec.name + # TODO: limit to only zen4 in the future + parse_hook_zen4_module_only(ec, eprefix) + # inject the GPU property (if required) ec = inject_gpu_property(ec) @@ -353,6 +357,28 @@ def parse_hook_CP2K_remove_deps_for_aarch64(ec, *args, **kwargs): raise EasyBuildError("CP2K-specific hook triggered for non-CP2K easyconfig?!") +def parse_hook_zen4_module_only(ec, eprefix): + """ + Use --force --module-only if building a foss-2022b-based EasyConfig for Zen4. + This toolchain will not be supported on Zen4, so we will generate a modulefile + and have it print an LmodError. + """ + ecname, ecversion = ec['name'], ec['version'] + tcname, tcversion = ec['toolchain']['name'], ec['toolchain']['version'] + if ( + (tcname in ['foss', 'gompi'] and tcversion == '2022b') or + (tcname in ['GCC', 'GCCcore'] and LooseVersion(tcversion) == LooseVersion('12.2.0')) or + (ecname in ['foss', 'gompi'] and ecversion == '2022b') or + (ecname in ['GCC', 'GCCcore'] and LooseVersion(ecversion) == LooseVersion('12.2.0')) + ): + update_build_option('force', 'True') + update_build_option('module_only', 'True') + # TODO: create a docs page to which we can refer for more info here + # TODO: then update the link to the known issues page to the _specific_ issue + errmsg = "Toolchains based on GCCcore-12.2.0 are not supported for the Zen4 architecture." + errmsg += " See https://www.eessi.io/docs/known_issues/eessi-2023.06/" + ec['modluafooter'] = 'LmodError(%s)' % errmsg + def pre_prepare_hook_highway_handle_test_compilation_issues(self, *args, **kwargs): """ Solve issues with compiling or running the tests on both From 9bb52dcbdcc61841739acc817135ba9a293f489b Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Wed, 11 Dec 2024 12:03:37 +0100 Subject: [PATCH 2/8] This works, but we should probably set the environment variable in one of the step-hooks, so we can unset it at the end --- eb_hooks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eb_hooks.py b/eb_hooks.py index b445754d83..0b30db9b4d 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -371,13 +371,17 @@ def parse_hook_zen4_module_only(ec, eprefix): (ecname in ['foss', 'gompi'] and ecversion == '2022b') or (ecname in ['GCC', 'GCCcore'] and LooseVersion(ecversion) == LooseVersion('12.2.0')) ): + env_varname="EESSI_IGNORE_LMOD_ERROR_ZEN4_GCC1220" + # TODO: I need to think about how to unset this, at the end of the build for this module + # Maybe I shouldn't do it in the parse hook, but set it in a step hook, and unset it in a another step hook? + os.environ[env_varname] = "1" update_build_option('force', 'True') update_build_option('module_only', 'True') # TODO: create a docs page to which we can refer for more info here # TODO: then update the link to the known issues page to the _specific_ issue errmsg = "Toolchains based on GCCcore-12.2.0 are not supported for the Zen4 architecture." errmsg += " See https://www.eessi.io/docs/known_issues/eessi-2023.06/" - ec['modluafooter'] = 'LmodError(%s)' % errmsg + ec['modluafooter'] = 'if (not os.getenv("%s")) then LmodError("%s") end' % (env_varname, errmsg) def pre_prepare_hook_highway_handle_test_compilation_issues(self, *args, **kwargs): """ From c26a1e54362ef585fae4576df5998257fbed8aec Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Wed, 11 Dec 2024 14:18:03 +0100 Subject: [PATCH 3/8] Only set env var for prepare step --- eb_hooks.py | 75 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/eb_hooks.py b/eb_hooks.py index 0b30db9b4d..cb8e759a7a 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -35,6 +35,20 @@ EESSI_INSTALLATION_REGEX = r"^/cvmfs/[^/]*.eessi.io/versions/" HOST_INJECTIONS_LOCATION = "/cvmfs/software.eessi.io/host_injections/" +# Make sure a single environment variable name is used for this throughout the hooks +EESSI_IGNORE_ZEN4_GCC1220_ENVVAR="EESSI_IGNORE_LMOD_ERROR_ZEN4_GCC1220" + +def is_gcccore_1220_based(ecname, ecversion, tcname, tcversion): + """Checks if this easyconfig either _is_ or _uses_ a GCCcore-12.2.2 based toolchain""" + gcccore_based_names = ['GCCcore', 'GCC'] + foss_based_names = ['gfbf', 'gompi', 'foss'] + return ( + (tcname in foss_based_names and tcversion == '2022b') or + (tcname in gcccore_based_names and LooseVersion(tcversion) == LooseVersion('12.2.0')) or + (ecname in foss_based_names and ecversion == '2022b') or + (ecname in gcccore_based_names and LooseVersion(ecversion) == LooseVersion('12.2.0')) + ) + def get_eessi_envvar(eessi_envvar): """Get an EESSI environment variable from the environment""" @@ -78,8 +92,9 @@ def parse_hook(ec, *args, **kwargs): PARSE_HOOKS[ec.name](ec, eprefix) # Always trigger this one, regardless of ec.name - # TODO: limit to only zen4 in the future - parse_hook_zen4_module_only(ec, eprefix) + cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') + if cpu_target == CPU_TARGET_ZEN4: + parse_hook_zen4_module_only(ec, eprefix) # inject the GPU property (if required) ec = inject_gpu_property(ec) @@ -134,6 +149,11 @@ def pre_prepare_hook(self, *args, **kwargs): if self.name in PRE_PREPARE_HOOKS: PRE_PREPARE_HOOKS[self.name](self, *args, **kwargs) + # Always trigger this one, regardless of ec.name + cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') + if cpu_target == CPU_TARGET_ZEN4: + pre_prepare_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs) + def post_prepare_hook_gcc_prefixed_ld_rpath_wrapper(self, *args, **kwargs): """ @@ -179,6 +199,11 @@ def post_prepare_hook(self, *args, **kwargs): if self.name in POST_PREPARE_HOOKS: POST_PREPARE_HOOKS[self.name](self, *args, **kwargs) + # Always trigger this one, regardless of ec.name + cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') + if cpu_target == CPU_TARGET_ZEN4: + post_prepare_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs) + def parse_hook_casacore_disable_vectorize(ec, eprefix): """ @@ -363,26 +388,44 @@ def parse_hook_zen4_module_only(ec, eprefix): This toolchain will not be supported on Zen4, so we will generate a modulefile and have it print an LmodError. """ - ecname, ecversion = ec['name'], ec['version'] - tcname, tcversion = ec['toolchain']['name'], ec['toolchain']['version'] - if ( - (tcname in ['foss', 'gompi'] and tcversion == '2022b') or - (tcname in ['GCC', 'GCCcore'] and LooseVersion(tcversion) == LooseVersion('12.2.0')) or - (ecname in ['foss', 'gompi'] and ecversion == '2022b') or - (ecname in ['GCC', 'GCCcore'] and LooseVersion(ecversion) == LooseVersion('12.2.0')) - ): - env_varname="EESSI_IGNORE_LMOD_ERROR_ZEN4_GCC1220" - # TODO: I need to think about how to unset this, at the end of the build for this module - # Maybe I shouldn't do it in the parse hook, but set it in a step hook, and unset it in a another step hook? - os.environ[env_varname] = "1" + if is_gcccore_1220_based(ec['name'], ec['version'], ec['toolchain']['name'], ec['toolchain']['version']): + env_varname=EESSI_IGNORE_ZEN4_GCC1220_ENVVAR update_build_option('force', 'True') update_build_option('module_only', 'True') # TODO: create a docs page to which we can refer for more info here # TODO: then update the link to the known issues page to the _specific_ issue - errmsg = "Toolchains based on GCCcore-12.2.0 are not supported for the Zen4 architecture." - errmsg += " See https://www.eessi.io/docs/known_issues/eessi-2023.06/" + # Need to escape newline character so that the newline character actually ends up in the module file + # (otherwise, it splits the string, and a 2-line string ends up in the modulefile, resulting in syntax error) + errmsg = "EasyConfigs using toolchains based on GCCcore-12.2.0 are not supported for the Zen4 architecture.\\n" + errmsg += "See https://www.eessi.io/docs/known_issues/eessi-2023.06/" ec['modluafooter'] = 'if (not os.getenv("%s")) then LmodError("%s") end' % (env_varname, errmsg) + +def pre_fetch_hook(ec, *args, **kwargs): + """Main parse hook: trigger custom functions based on software name.""" + + if ec.name in PRE_FETCH_HOOKS: + PRE_FETCH_HOOKS[ec.name](ec, *args, **kwargs) + + # Always trigger this one, regardless of ec.name + cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') + if cpu_target == CPU_TARGET_ZEN4: + pre_fetch_hook_ignore_zen4_gcccore1220_error(ec, *args, **kwargs) + + +# We do this as early as possible - and remove it all the way in the last step hook (post_testcases_hook) +def pre_prepare_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): + """Set environment variable to ignore the LmodError from parse_hook_zen4_module_only during build phase""" + if is_gcccore_1220_based(self.name, self.version, self.toolchain.name, self.toolchain.version): + os.environ[EESSI_IGNORE_ZEN4_GCC1220_ENVVAR] = "1" + + +def post_prepare_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): + """Unset environment variable to ignore the LmodError from parse_hook_zen4_module_only during build phase""" + if is_gcccore_1220_based(self.name, self.version, self.toolchain.name, self.toolchain.version): + del os.environ[EESSI_IGNORE_ZEN4_GCC1220_ENVVAR] + + def pre_prepare_hook_highway_handle_test_compilation_issues(self, *args, **kwargs): """ Solve issues with compiling or running the tests on both From 600adee5699660b5aa79f5d2c19c07ae8e3864ea Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Wed, 11 Dec 2024 14:28:51 +0100 Subject: [PATCH 4/8] Remove unused code --- eb_hooks.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/eb_hooks.py b/eb_hooks.py index cb8e759a7a..f9580b46d0 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -401,18 +401,6 @@ def parse_hook_zen4_module_only(ec, eprefix): ec['modluafooter'] = 'if (not os.getenv("%s")) then LmodError("%s") end' % (env_varname, errmsg) -def pre_fetch_hook(ec, *args, **kwargs): - """Main parse hook: trigger custom functions based on software name.""" - - if ec.name in PRE_FETCH_HOOKS: - PRE_FETCH_HOOKS[ec.name](ec, *args, **kwargs) - - # Always trigger this one, regardless of ec.name - cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') - if cpu_target == CPU_TARGET_ZEN4: - pre_fetch_hook_ignore_zen4_gcccore1220_error(ec, *args, **kwargs) - - # We do this as early as possible - and remove it all the way in the last step hook (post_testcases_hook) def pre_prepare_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): """Set environment variable to ignore the LmodError from parse_hook_zen4_module_only during build phase""" From b3fade96749ea22e867ffac8ecd850edae95ef40 Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Wed, 11 Dec 2024 15:40:19 +0100 Subject: [PATCH 5/8] Use step hooks to set and unset force and module-only --- eb_hooks.py | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/eb_hooks.py b/eb_hooks.py index f9580b46d0..ddfbc37692 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -29,6 +29,8 @@ CPU_TARGET_ZEN4 = 'x86_64/amd/zen4' EESSI_RPATH_OVERRIDE_ATTR = 'orig_rpath_override_dirs' +EESSI_MODULE_ONLY_ATTR = 'orig_module_only' +EESSI_FORCE_ATTR = 'orig_force' SYSTEM = EASYCONFIG_CONSTANTS['SYSTEM'][0] @@ -389,9 +391,9 @@ def parse_hook_zen4_module_only(ec, eprefix): and have it print an LmodError. """ if is_gcccore_1220_based(ec['name'], ec['version'], ec['toolchain']['name'], ec['toolchain']['version']): - env_varname=EESSI_IGNORE_ZEN4_GCC1220_ENVVAR - update_build_option('force', 'True') - update_build_option('module_only', 'True') + env_varname = EESSI_IGNORE_ZEN4_GCC1220_ENVVAR + # update_build_option('force', 'True') + # update_build_option('module_only', 'True') # TODO: create a docs page to which we can refer for more info here # TODO: then update the link to the known issues page to the _specific_ issue # Need to escape newline character so that the newline character actually ends up in the module file @@ -401,6 +403,56 @@ def parse_hook_zen4_module_only(ec, eprefix): ec['modluafooter'] = 'if (not os.getenv("%s")) then LmodError("%s") end' % (env_varname, errmsg) +def pre_fetch_hook(self, *args, **kwargs): + """Main pre fetch hook: trigger custom functions based on software name.""" + if self.name in PRE_FETCH_HOOKS: + PRE_FETCH_HOOKS[ec.name](self, *args, **kwargs) + + # Always trigger this one, regardless of self.name + cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') + if cpu_target == CPU_TARGET_ZEN4: + pre_fetch_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs) + + +def pre_fetch_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): + """Use --force --module-only if building a foss-2022b-based EasyConfig for Zen4. + This toolchain will not be supported on Zen4, so we will generate a modulefile + and have it print an LmodError. + """ + if is_gcccore_1220_based(self.name, self.version, self.toolchain.name, self.toolchain.version): + if hasattr(self, EESSI_MODULE_ONLY_ATTR): + raise EasyBuildError("'self' already has attribute %s! Can't use pre_fetch hook.", + EESSI_MODULE_ONLY_ATTR) + setattr(self, EESSI_MODULE_ONLY_ATTR, build_option('module_only')) + update_build_option('module_only', 'True') + print_msg("Updated build option 'module-only' to 'True'") + + if hasattr(self, EESSI_FORCE_ATTR): + raise EasyBuildError("'self' already has attribute %s! Can't use pre_fetch hook.", + EESSI_FORCE_ATTR) + setattr(self, EESSI_FORCE_ATTR, build_option('force')) + update_build_option('force', 'True') + print_msg("Updated build option 'force' to 'True'") + + +def post_module_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): + """Revert changes from pre_fetch_hook_ignore_zen4_gcccore1220_error""" + if is_gcccore_1220_based(self.name, self.version, self.toolchain.name, self.toolchain.version): + if hasattr(self, EESSI_MODULE_ONLY_ATTR): + update_build_option('module_only', getattr(self, EESSI_MODULE_ONLY_ATTR)) + print_msg("Restored original build option 'module_only' to %s" % getattr(self, EESSI_MODULE_ONLY_ATTR)) + else: + raise EasyBuildError("Cannot restore module_only to it's original value: 'self' is missing attribute %s.", + EESSI_MODULE_ONLY_ATTR) + + if hasattr(self, EESSI_FORCE_ATTR): + update_build_option('force', getattr(self, EESSI_FORCE_ATTR)) + print_msg("Restored original build option 'force' to %s" % getattr(self, EESSI_FORCE_ATTR)) + else: + raise EasyBuildError("Cannot restore force to it's original value: 'self' is misisng attribute %s.", + EESSI_FORCE_ATTR) + + # We do this as early as possible - and remove it all the way in the last step hook (post_testcases_hook) def pre_prepare_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): """Set environment variable to ignore the LmodError from parse_hook_zen4_module_only during build phase""" @@ -1028,6 +1080,17 @@ def inject_gpu_property(ec): return ec +def post_module_hook(self, *args, **kwargs): + """Main post module hook: trigger custom functions based on software name.""" + if self.name in POST_MODULE_HOOKS: + POST_MODULE_HOOKS[ec.name](self, *args, **kwargs) + + # Always trigger this one, regardless of self.name + cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') + if cpu_target == CPU_TARGET_ZEN4: + post_module_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs) + + PARSE_HOOKS = { 'casacore': parse_hook_casacore_disable_vectorize, 'CGAL': parse_hook_cgal_toolchainopts_precise, @@ -1042,6 +1105,8 @@ def inject_gpu_property(ec): 'UCX': parse_hook_ucx_eprefix, } +PRE_FETCH_HOOKS = {} + PRE_PREPARE_HOOKS = { 'Highway': pre_prepare_hook_highway_handle_test_compilation_issues, } @@ -1087,3 +1152,5 @@ def inject_gpu_property(ec): 'CUDA': post_postproc_cuda, 'cuDNN': post_postproc_cudnn, } + +POST_MODULE_HOOKS = {} From 6a1700ef648e8e0026a352aa63f4e855bc2d664c Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Wed, 11 Dec 2024 15:46:07 +0100 Subject: [PATCH 6/8] Rename hooks to make more sense --- eb_hooks.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/eb_hooks.py b/eb_hooks.py index ddfbc37692..3223286f82 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -392,8 +392,6 @@ def parse_hook_zen4_module_only(ec, eprefix): """ if is_gcccore_1220_based(ec['name'], ec['version'], ec['toolchain']['name'], ec['toolchain']['version']): env_varname = EESSI_IGNORE_ZEN4_GCC1220_ENVVAR - # update_build_option('force', 'True') - # update_build_option('module_only', 'True') # TODO: create a docs page to which we can refer for more info here # TODO: then update the link to the known issues page to the _specific_ issue # Need to escape newline character so that the newline character actually ends up in the module file @@ -411,10 +409,10 @@ def pre_fetch_hook(self, *args, **kwargs): # Always trigger this one, regardless of self.name cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') if cpu_target == CPU_TARGET_ZEN4: - pre_fetch_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs) + pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs) -def pre_fetch_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): +def pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs): """Use --force --module-only if building a foss-2022b-based EasyConfig for Zen4. This toolchain will not be supported on Zen4, so we will generate a modulefile and have it print an LmodError. @@ -435,8 +433,8 @@ def pre_fetch_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): print_msg("Updated build option 'force' to 'True'") -def post_module_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): - """Revert changes from pre_fetch_hook_ignore_zen4_gcccore1220_error""" +def post_module_hook_zen4_gcccore1220(self, *args, **kwargs): + """Revert changes from pre_fetch_hook_zen4_gcccore1220""" if is_gcccore_1220_based(self.name, self.version, self.toolchain.name, self.toolchain.version): if hasattr(self, EESSI_MODULE_ONLY_ATTR): update_build_option('module_only', getattr(self, EESSI_MODULE_ONLY_ATTR)) @@ -1088,7 +1086,7 @@ def post_module_hook(self, *args, **kwargs): # Always trigger this one, regardless of self.name cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') if cpu_target == CPU_TARGET_ZEN4: - post_module_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs) + post_module_hook_zen4_gcccore1220(self, *args, **kwargs) PARSE_HOOKS = { From 78542d1dfdaee9f56f5bd8fa49ea375c9279a3d4 Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Tue, 7 Jan 2025 10:33:03 +0100 Subject: [PATCH 7/8] Processed Alan's comments --- eb_hooks.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/eb_hooks.py b/eb_hooks.py index 3223286f82..59e19e4f3c 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -40,8 +40,23 @@ # Make sure a single environment variable name is used for this throughout the hooks EESSI_IGNORE_ZEN4_GCC1220_ENVVAR="EESSI_IGNORE_LMOD_ERROR_ZEN4_GCC1220" -def is_gcccore_1220_based(ecname, ecversion, tcname, tcversion): - """Checks if this easyconfig either _is_ or _uses_ a GCCcore-12.2.2 based toolchain""" +def is_gcccore_1220_based(**kwargs): +# ecname, ecversion, tcname, tcversion): + """ + Checks if this easyconfig either _is_ or _uses_ a GCCcore-12.2.0 based toolchain. + This function is, for example, used to generate errors in GCCcore-12.2.0 based modules for the zen4 architecture + since zen4 is not fully supported with that toolchain. + + :param str ecname: Name of the software specified in the EasyConfig + :param str ecversion: Version of the software specified in the EasyConfig + :param str tcname: Toolchain name specified in the EasyConfig + :param str tcversion: Toolchain version specified in the EasyConfig + """ + ecname = kwargs.get['ecname', None] + ecversion = kwargs.get['ecversion', None] + tcname = kwargs.get['tcname', None] + tcversion = kwargs.get['tcversion', None] + gcccore_based_names = ['GCCcore', 'GCC'] foss_based_names = ['gfbf', 'gompi', 'foss'] return ( @@ -397,7 +412,7 @@ def parse_hook_zen4_module_only(ec, eprefix): # Need to escape newline character so that the newline character actually ends up in the module file # (otherwise, it splits the string, and a 2-line string ends up in the modulefile, resulting in syntax error) errmsg = "EasyConfigs using toolchains based on GCCcore-12.2.0 are not supported for the Zen4 architecture.\\n" - errmsg += "See https://www.eessi.io/docs/known_issues/eessi-2023.06/" + errmsg += "See https://www.eessi.io/docs/known_issues/eessi-2023.06/#gcc-1220-and-foss-2022b-based-modules-cannot-be-loaded-on-zen4-architecture" ec['modluafooter'] = 'if (not os.getenv("%s")) then LmodError("%s") end' % (env_varname, errmsg) @@ -451,7 +466,9 @@ def post_module_hook_zen4_gcccore1220(self, *args, **kwargs): EESSI_FORCE_ATTR) -# We do this as early as possible - and remove it all the way in the last step hook (post_testcases_hook) +# Modules for dependencies are loaded in the prepare step. Thus, that's where we need this variable to be set +# so that the modules can be succesfully loaded without printing the error (so that we can create a module +# _with_ the warning for the current software being installed) def pre_prepare_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): """Set environment variable to ignore the LmodError from parse_hook_zen4_module_only during build phase""" if is_gcccore_1220_based(self.name, self.version, self.toolchain.name, self.toolchain.version): From 54abb683507f0782863be6718b72fd99581a57c8 Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Tue, 7 Jan 2025 12:11:36 +0100 Subject: [PATCH 8/8] Fix formatting --- eb_hooks.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/eb_hooks.py b/eb_hooks.py index 59e19e4f3c..08eb5ea62e 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -52,10 +52,10 @@ def is_gcccore_1220_based(**kwargs): :param str tcname: Toolchain name specified in the EasyConfig :param str tcversion: Toolchain version specified in the EasyConfig """ - ecname = kwargs.get['ecname', None] - ecversion = kwargs.get['ecversion', None] - tcname = kwargs.get['tcname', None] - tcversion = kwargs.get['tcversion', None] + ecname = kwargs.get('ecname', None) + ecversion = kwargs.get('ecversion', None) + tcname = kwargs.get('tcname', None) + tcversion = kwargs.get('tcversion', None) gcccore_based_names = ['GCCcore', 'GCC'] foss_based_names = ['gfbf', 'gompi', 'foss'] @@ -405,7 +405,8 @@ def parse_hook_zen4_module_only(ec, eprefix): This toolchain will not be supported on Zen4, so we will generate a modulefile and have it print an LmodError. """ - if is_gcccore_1220_based(ec['name'], ec['version'], ec['toolchain']['name'], ec['toolchain']['version']): + if is_gcccore_1220_based(ecname=ec['name'], ecversion=ec['version'], tcname=ec['toolchain']['name'], + tcversion=ec['toolchain']['version']): env_varname = EESSI_IGNORE_ZEN4_GCC1220_ENVVAR # TODO: create a docs page to which we can refer for more info here # TODO: then update the link to the known issues page to the _specific_ issue @@ -432,7 +433,8 @@ def pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs): This toolchain will not be supported on Zen4, so we will generate a modulefile and have it print an LmodError. """ - if is_gcccore_1220_based(self.name, self.version, self.toolchain.name, self.toolchain.version): + if is_gcccore_1220_based(ecname=self.name, ecversion=self.version, tcname=self.toolchain.name, + tcversion=self.toolchain.version): if hasattr(self, EESSI_MODULE_ONLY_ATTR): raise EasyBuildError("'self' already has attribute %s! Can't use pre_fetch hook.", EESSI_MODULE_ONLY_ATTR) @@ -450,7 +452,8 @@ def pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs): def post_module_hook_zen4_gcccore1220(self, *args, **kwargs): """Revert changes from pre_fetch_hook_zen4_gcccore1220""" - if is_gcccore_1220_based(self.name, self.version, self.toolchain.name, self.toolchain.version): + if is_gcccore_1220_based(ecname=self.name, ecversion=self.version, tcname=self.toolchain.name, + tcversion=self.toolchain.version): if hasattr(self, EESSI_MODULE_ONLY_ATTR): update_build_option('module_only', getattr(self, EESSI_MODULE_ONLY_ATTR)) print_msg("Restored original build option 'module_only' to %s" % getattr(self, EESSI_MODULE_ONLY_ATTR)) @@ -471,13 +474,15 @@ def post_module_hook_zen4_gcccore1220(self, *args, **kwargs): # _with_ the warning for the current software being installed) def pre_prepare_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): """Set environment variable to ignore the LmodError from parse_hook_zen4_module_only during build phase""" - if is_gcccore_1220_based(self.name, self.version, self.toolchain.name, self.toolchain.version): + if is_gcccore_1220_based(ecname=self.name, ecversion=self.version, tcname=self.toolchain.name, + tcversion=self.toolchain.version): os.environ[EESSI_IGNORE_ZEN4_GCC1220_ENVVAR] = "1" def post_prepare_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs): """Unset environment variable to ignore the LmodError from parse_hook_zen4_module_only during build phase""" - if is_gcccore_1220_based(self.name, self.version, self.toolchain.name, self.toolchain.version): + if is_gcccore_1220_based(ecname=self.name, ecversion=self.version, tcname=self.toolchain.name, + tcversion=self.toolchain.version): del os.environ[EESSI_IGNORE_ZEN4_GCC1220_ENVVAR]