Skip to content

Commit 18417ad

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

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

@@ -3363,6 +3363,16 @@ def post_processing_step(self):
33633363

33643364
def _dispatch_sanity_check_step(self, *args, **kwargs):
33653365
"""Decide whether to run the dry-run or the real version of the sanity-check step"""
3366+
if 'extension' in kwargs:
3367+
extension = kwargs.pop('extension')
3368+
self.log.deprecated(
3369+
"Passing `extension` to `sanity_check_step` is no longer necessary and will be ignored "
3370+
f"(Easyblock: {self.__class__.__name__}).",
3371+
'6.0',
3372+
)
3373+
if extension != self.is_extension:
3374+
raise EasyBuildError('Unexpected value for `extension` argument. '
3375+
f'Should be: {self.is_extension}, got: {extension}')
33663376
if self.dry_run:
33673377
self._sanity_check_step_dry_run(*args, **kwargs)
33683378
else:
@@ -4042,7 +4052,7 @@ def sanity_check_mod_files(self):
40424052

40434053
return fail_msg
40444054

4045-
def _sanity_check_step_common(self, custom_paths, custom_commands, is_extension=False):
4055+
def _sanity_check_step_common(self, custom_paths, custom_commands):
40464056
"""
40474057
Determine sanity check paths and commands to use.
40484058
@@ -4080,7 +4090,7 @@ def _sanity_check_step_common(self, custom_paths, custom_commands, is_extension=
40804090
for key in path_keys_and_check:
40814091
paths.setdefault(key, [])
40824092
# Default paths for extensions are handled in the parent easyconfig if desired
4083-
if not is_extension:
4093+
if not self.is_extension:
40844094
paths.update({SANITY_CHECK_PATHS_DIRS: ['bin', ('lib', 'lib64')]})
40854095
self.log.info("Using default sanity check paths: %s", paths)
40864096

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

@@ -4161,15 +4171,14 @@ def _sanity_check_step_common(self, custom_paths, custom_commands, is_extension=
41614171

41624172
return paths, path_keys_and_check, commands
41634173

4164-
def _sanity_check_step_dry_run(self, custom_paths=None, custom_commands=None, extension=False, **_):
4174+
def _sanity_check_step_dry_run(self, custom_paths=None, custom_commands=None, **_):
41654175
"""
41664176
Dry run version of sanity_check_step method.
41674177
41684178
:param custom_paths: custom sanity check paths to check existence for
41694179
:param custom_commands: custom sanity check commands to run
41704180
"""
4171-
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands,
4172-
is_extension=extension)
4181+
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands)
41734182

41744183
for key in [SANITY_CHECK_PATHS_FILES, SANITY_CHECK_PATHS_DIRS]:
41754184
(typ, _) = path_keys_and_check[key]
@@ -4264,7 +4273,7 @@ def sanity_check_load_module(self, extension=False, extra_modules=None):
42644273

42654274
return self.fake_mod_data
42664275

4267-
def _sanity_check_step(self, custom_paths=None, custom_commands=None, extension=False, extra_modules=None):
4276+
def _sanity_check_step(self, custom_paths=None, custom_commands=None, extra_modules=None):
42684277
"""
42694278
Real version of sanity_check_step method.
42704279
@@ -4273,8 +4282,7 @@ def _sanity_check_step(self, custom_paths=None, custom_commands=None, extension=
42734282
:param extension: indicates whether or not sanity check is run for an extension
42744283
:param extra_modules: extra modules to load before running sanity check commands
42754284
"""
4276-
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands,
4277-
is_extension=extension)
4285+
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands)
42784286

42794287
# helper function to sanity check (alternatives for) one particular path
42804288
def check_path(xs, typ, check_fn):
@@ -4331,7 +4339,7 @@ def xs2str(xs):
43314339
trace_msg("%s %s found: %s" % (typ, xs2str(xs), ('FAILED', 'OK')[found]))
43324340

43334341
if not self.sanity_check_module_loaded:
4334-
self.sanity_check_load_module(extension=extension, extra_modules=extra_modules)
4342+
self.sanity_check_load_module(extension=self.is_extension, extra_modules=extra_modules)
43354343

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

43624370
# also run sanity check for extensions (unless we are an extension ourselves)
4363-
if not extension:
4371+
if not self.is_extension:
43644372
if build_option('skip_extensions'):
43654373
self.log.info("Skipping sanity check for extensions since skip-extensions is enabled...")
43664374
else:
@@ -4412,7 +4420,7 @@ def xs2str(xs):
44124420
# pass or fail
44134421
if not self.sanity_check_fail_msgs:
44144422
self.log.debug("Sanity check passed!")
4415-
elif not extension:
4423+
elif not self.is_extension:
44164424
raise EasyBuildError(
44174425
"Sanity check failed: " + '\n'.join(self.sanity_check_fail_msgs),
44184426
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)