Skip to content
Merged
Show file tree
Hide file tree
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
54 changes: 43 additions & 11 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
from easybuild.tools.build_log import EasyBuildError, EasyBuildExit, dry_run_msg, dry_run_warning, dry_run_set_dirs
from easybuild.tools.build_log import print_error_and_exit, print_msg, print_warning
from easybuild.tools.config import CHECKSUM_PRIORITY_JSON, DEFAULT_ENVVAR_USERS_MODULES
from easybuild.tools.config import EASYBUILD_SOURCES_URL, EBPYTHONPREFIXES # noqa
from easybuild.tools.config import EASYBUILD_SOURCES_URL, EBPYTHONPREFIXES # noqa # pylint:disable=unused-import
from easybuild.tools.config import FORCE_DOWNLOAD_ALL, FORCE_DOWNLOAD_PATCHES, FORCE_DOWNLOAD_SOURCES
from easybuild.tools.config import MOD_SEARCH_PATH_HEADERS, PYTHONPATH, SEARCH_PATH_BIN_DIRS, SEARCH_PATH_LIB_DIRS
from easybuild.tools.config import build_option, build_path, get_failed_install_build_dirs_path
Expand Down Expand Up @@ -3442,6 +3442,16 @@ def post_processing_step(self):

def _dispatch_sanity_check_step(self, *args, **kwargs):
"""Decide whether to run the dry-run or the real version of the sanity-check step"""
if 'extension' in kwargs:
extension = kwargs.pop('extension')
self.log.deprecated(
"Passing `extension` to `sanity_check_step` is no longer necessary "
f"(Easyblock: {self.__class__.__name__}).",
'6.0',
)
if extension != self.is_extension:
raise EasyBuildError('Unexpected value for `extension` argument. '
f'Should be: {self.is_extension}, got: {extension}')
if self.dry_run:
self._sanity_check_step_dry_run(*args, **kwargs)
else:
Expand Down Expand Up @@ -4310,23 +4320,34 @@ def _sanity_check_step_extensions(self):
self.sanity_check_fail_msgs.append(overall_fail_msg + ', '.join(x[0] for x in failed_exts))
self.sanity_check_fail_msgs.extend(x[1] for x in failed_exts)

def sanity_check_load_module(self, extension=False, extra_modules=None):
def sanity_check_load_module(self, extension=None, extra_modules=None):
"""
Load module to prepare environment for sanity check
:param extension: DEPRECATED: indicates whether this method is called for an extension
"""
if extension is not None:
self.log.deprecated(
"Passing `extension` to `sanity_check_load_module` is no longer necessary "
f"(Easyblock: {self.__class__.__name__}).",
'6.0',
)
if extension != self.is_extension:
raise EasyBuildError('Unexpected value for `extension` argument. '
f'Should be: {self.is_extension}, got: {extension}')
del extension # Avoid accidental use

if self.is_extension:
return self.fake_mod_data

# skip loading of fake module when using --sanity-check-only, load real module instead
if build_option('sanity_check_only') and not extension:
if build_option('sanity_check_only'):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this still check self.extension?

Suggested change
if build_option('sanity_check_only'):
if build_option('sanity_check_only') and not self.extension:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, no, because of the inline return above...

self.log.info("Loading real module for %s %s: %s", self.name, self.version, self.short_mod_name)
self.load_module(extra_modules=extra_modules)
self.sanity_check_module_loaded = True

# only load fake module for non-extensions, and not during dry run
elif not (extension or self.dry_run):

elif not (self.is_extension or self.dry_run):
if extra_modules:
self.log.info("Loading extra modules for sanity check: %s", ', '.join(extra_modules))

try:
# unload all loaded modules before loading fake module
# this ensures that loading of dependencies is tested, and avoids conflicts with build dependencies
Expand All @@ -4338,15 +4359,26 @@ def sanity_check_load_module(self, extension=False, extra_modules=None):

return self.fake_mod_data

def _sanity_check_step(self, custom_paths=None, custom_commands=None, extension=False, extra_modules=None):
def _sanity_check_step(self, custom_paths=None, custom_commands=None, extension=None, extra_modules=None):
"""
Real version of sanity_check_step method.

:param custom_paths: custom sanity check paths to check existence for
:param custom_commands: custom sanity check commands to run
:param extension: indicates whether or not sanity check is run for an extension
:param extension: DEPRECATED: indicated whether sanity check is run for an extension, now ignored
:param extra_modules: extra modules to load before running sanity check commands
"""
if extension is not None:
self.log.deprecated(
"Passing `extension` to `sanity_check_step` is no longer necessary "
f"(Easyblock: {self.__class__.__name__}).",
'6.0',
)
if extension != self.is_extension:
raise EasyBuildError('Unexpected value for `extension` argument. '
f'Should be: {self.is_extension}, got: {extension}')
del extension # Avoid accidental use

paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands)

# helper function to sanity check (alternatives for) one particular path
Expand Down Expand Up @@ -4404,7 +4436,7 @@ def xs2str(xs):
trace_msg("%s %s found: %s" % (typ, xs2str(xs), ('FAILED', 'OK')[found]))

if not self.sanity_check_module_loaded:
self.sanity_check_load_module(extension=extension, extra_modules=extra_modules)
self.sanity_check_load_module(extra_modules=extra_modules)

# allow oversubscription of P processes on C cores (P>C) for software installed on top of Open MPI;
# this is useful to avoid failing of sanity check commands that involve MPI
Expand Down Expand Up @@ -4433,7 +4465,7 @@ def xs2str(xs):
trace_msg(f"result for command '{cmd}': {cmd_result_str}")

# also run sanity check for extensions (unless we are an extension ourselves)
if not extension:
if not self.is_extension:
if build_option('skip_extensions'):
self.log.info("Skipping sanity check for extensions since skip-extensions is enabled...")
else:
Expand Down
3 changes: 1 addition & 2 deletions easybuild/framework/extensioneasyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ def sanity_check_step(self, exts_filter=None, custom_paths=None, custom_commands

if custom_paths or custom_commands or not self.is_extension:
super().sanity_check_step(custom_paths=custom_paths,
custom_commands=custom_commands,
extension=self.is_extension)
custom_commands=custom_commands)

# pass or fail sanity check
if sanity_check_ok:
Expand Down