Skip to content

Commit 5943e1d

Browse files
committed
Remove extension parameter from sanity_check_steps methods
It is redundant as `self.is_extension` provides that information already.
1 parent 1e8bb05 commit 5943e1d

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

easybuild/framework/easyblock.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def __init__(self, ec, logfile=None):
208208
self.skip = None
209209
self.module_extra_extensions = '' # extra stuff for module file required by extensions
210210

211-
# indicates whether or not this instance represents an extension or not;
211+
# indicates whether or not this instance represents an extension
212212
# may be set to True by ExtensionEasyBlock
213213
self.is_extension = False
214214

@@ -3360,6 +3360,16 @@ def post_processing_step(self):
33603360

33613361
def _dispatch_sanity_check_step(self, *args, **kwargs):
33623362
"""Decide whether to run the dry-run or the real version of the sanity-check step"""
3363+
if 'extension' in kwargs:
3364+
extension = kwargs.pop('extension')
3365+
self.log.deprecated(
3366+
"Passing `extension` to `sanity_check_step` is no longer necessary and will be ignored "
3367+
f"(Easyblock: {self.__class__.__name__}).",
3368+
'6.0',
3369+
)
3370+
if extension != self.is_extension:
3371+
raise EasyBuildError('Unexpected value for `extension` argument. '
3372+
f'Should be: {self.is_extension}, got: {extension}')
33633373
if self.dry_run:
33643374
self._sanity_check_step_dry_run(*args, **kwargs)
33653375
else:
@@ -4039,7 +4049,7 @@ def sanity_check_mod_files(self):
40394049

40404050
return fail_msg
40414051

4042-
def _sanity_check_step_common(self, custom_paths, custom_commands, is_extension=False):
4052+
def _sanity_check_step_common(self, custom_paths, custom_commands):
40434053
"""
40444054
Determine sanity check paths and commands to use.
40454055
@@ -4077,7 +4087,7 @@ def _sanity_check_step_common(self, custom_paths, custom_commands, is_extension=
40774087
for key in path_keys_and_check:
40784088
paths.setdefault(key, [])
40794089
# Default paths for extensions are handled in the parent easyconfig if desired
4080-
if not is_extension:
4090+
if not self.is_extension:
40814091
paths.update({SANITY_CHECK_PATHS_DIRS: ['bin', ('lib', 'lib64')]})
40824092
self.log.info("Using default sanity check paths: %s", paths)
40834093

@@ -4099,10 +4109,10 @@ def _sanity_check_step_common(self, custom_paths, custom_commands, is_extension=
40994109
# verify sanity_check_paths value: only known keys, correct value types, at least one non-empty value
41004110
only_list_values = all(isinstance(x, list) for x in paths.values())
41014111
only_empty_lists = all(not x for x in paths.values())
4102-
if sorted_keys != known_keys or not only_list_values or (only_empty_lists and not is_extension):
4112+
if sorted_keys != known_keys or not only_list_values or (only_empty_lists and not self.is_extension):
41034113
error_msg = "Incorrect format for sanity_check_paths: should (only) have %s keys, "
41044114
error_msg += "values should be lists"
4105-
if not is_extension:
4115+
if not self.is_extension:
41064116
error_msg += " (at least one non-empty)."
41074117
raise EasyBuildError(error_msg % ', '.join("'%s'" % k for k in known_keys))
41084118

@@ -4158,15 +4168,14 @@ def _sanity_check_step_common(self, custom_paths, custom_commands, is_extension=
41584168

41594169
return paths, path_keys_and_check, commands
41604170

4161-
def _sanity_check_step_dry_run(self, custom_paths=None, custom_commands=None, extension=False, **_):
4171+
def _sanity_check_step_dry_run(self, custom_paths=None, custom_commands=None, **_):
41624172
"""
41634173
Dry run version of sanity_check_step method.
41644174
41654175
:param custom_paths: custom sanity check paths to check existence for
41664176
:param custom_commands: custom sanity check commands to run
41674177
"""
4168-
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands,
4169-
is_extension=extension)
4178+
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands)
41704179

41714180
for key in [SANITY_CHECK_PATHS_FILES, SANITY_CHECK_PATHS_DIRS]:
41724181
(typ, _) = path_keys_and_check[key]
@@ -4261,7 +4270,7 @@ def sanity_check_load_module(self, extension=False, extra_modules=None):
42614270

42624271
return self.fake_mod_data
42634272

4264-
def _sanity_check_step(self, custom_paths=None, custom_commands=None, extension=False, extra_modules=None):
4273+
def _sanity_check_step(self, custom_paths=None, custom_commands=None, extra_modules=None):
42654274
"""
42664275
Real version of sanity_check_step method.
42674276
@@ -4270,8 +4279,7 @@ def _sanity_check_step(self, custom_paths=None, custom_commands=None, extension=
42704279
:param extension: indicates whether or not sanity check is run for an extension
42714280
:param extra_modules: extra modules to load before running sanity check commands
42724281
"""
4273-
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands,
4274-
is_extension=extension)
4282+
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands)
42754283

42764284
# helper function to sanity check (alternatives for) one particular path
42774285
def check_path(xs, typ, check_fn):
@@ -4328,7 +4336,7 @@ def xs2str(xs):
43284336
trace_msg("%s %s found: %s" % (typ, xs2str(xs), ('FAILED', 'OK')[found]))
43294337

43304338
if not self.sanity_check_module_loaded:
4331-
self.sanity_check_load_module(extension=extension, extra_modules=extra_modules)
4339+
self.sanity_check_load_module(extension=self.is_extension, extra_modules=extra_modules)
43324340

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

43594367
# also run sanity check for extensions (unless we are an extension ourselves)
4360-
if not extension:
4368+
if not self.is_extension:
43614369
if build_option('skip_extensions'):
43624370
self.log.info("Skipping sanity check for extensions since skip-extensions is enabled...")
43634371
else:
@@ -4409,7 +4417,7 @@ def xs2str(xs):
44094417
# pass or fail
44104418
if not self.sanity_check_fail_msgs:
44114419
self.log.debug("Sanity check passed!")
4412-
elif not extension:
4420+
elif not self.is_extension:
44134421
raise EasyBuildError(
44144422
"Sanity check failed: " + '\n'.join(self.sanity_check_fail_msgs),
44154423
exit_code=EasyBuildExit.FAIL_SANITY_CHECK,

easybuild/framework/extensioneasyblock.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ def extra_options(extra_vars=None):
7272
def __init__(self, *args, **kwargs):
7373
"""Initialize either as EasyBlock or as Extension."""
7474

75-
self.is_extension = False
76-
7775
if isinstance(args[0], EasyBlock):
7876
# make sure that extra custom easyconfig parameters are known
7977
extra_params = self.__class__.extra_options()
@@ -193,8 +191,7 @@ def sanity_check_step(self, exts_filter=None, custom_paths=None, custom_commands
193191
Extension.sanity_check_step(self)
194192

195193
super().sanity_check_step(custom_paths=custom_paths,
196-
custom_commands=custom_commands,
197-
extension=self.is_extension)
194+
custom_commands=custom_commands)
198195

199196
# pass or fail sanity check
200197
if not self.sanity_check_fail_msgs:

0 commit comments

Comments
 (0)