Skip to content

Commit eda13d6

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

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
@@ -209,7 +209,7 @@ def __init__(self, ec, logfile=None):
209209
self.skip = None
210210
self.module_extra_extensions = '' # extra stuff for module file required by extensions
211211

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

@@ -3391,6 +3391,16 @@ def post_processing_step(self):
33913391

33923392
def _dispatch_sanity_check_step(self, *args, **kwargs):
33933393
"""Decide whether to run the dry-run or the real version of the sanity-check step"""
3394+
if 'extension' in kwargs:
3395+
extension = kwargs.pop('extension')
3396+
self.log.deprecated(
3397+
"Passing `extension` to `sanity_check_step` is no longer necessary and will be ignored "
3398+
f"(Easyblock: {self.__class__.__name__}).",
3399+
'6.0',
3400+
)
3401+
if extension != self.is_extension:
3402+
raise EasyBuildError('Unexpected value for `extension` argument. '
3403+
f'Should be: {self.is_extension}, got: {extension}')
33943404
if self.dry_run:
33953405
self._sanity_check_step_dry_run(*args, **kwargs)
33963406
else:
@@ -4070,7 +4080,7 @@ def sanity_check_mod_files(self):
40704080

40714081
return fail_msg
40724082

4073-
def _sanity_check_step_common(self, custom_paths, custom_commands, is_extension=False):
4083+
def _sanity_check_step_common(self, custom_paths, custom_commands):
40744084
"""
40754085
Determine sanity check paths and commands to use.
40764086
@@ -4108,7 +4118,7 @@ def _sanity_check_step_common(self, custom_paths, custom_commands, is_extension=
41084118
for key in path_keys_and_check:
41094119
paths.setdefault(key, [])
41104120
# Default paths for extensions are handled in the parent easyconfig if desired
4111-
if not is_extension:
4121+
if not self.is_extension:
41124122
paths.update({SANITY_CHECK_PATHS_DIRS: ['bin', ('lib', 'lib64')]})
41134123
self.log.info("Using default sanity check paths: %s", paths)
41144124

@@ -4130,10 +4140,10 @@ def _sanity_check_step_common(self, custom_paths, custom_commands, is_extension=
41304140
# verify sanity_check_paths value: only known keys, correct value types, at least one non-empty value
41314141
only_list_values = all(isinstance(x, list) for x in paths.values())
41324142
only_empty_lists = all(not x for x in paths.values())
4133-
if sorted_keys != known_keys or not only_list_values or (only_empty_lists and not is_extension):
4143+
if sorted_keys != known_keys or not only_list_values or (only_empty_lists and not self.is_extension):
41344144
error_msg = "Incorrect format for sanity_check_paths: should (only) have %s keys, "
41354145
error_msg += "values should be lists"
4136-
if not is_extension:
4146+
if not self.is_extension:
41374147
error_msg += " (at least one non-empty)."
41384148
raise EasyBuildError(error_msg % ', '.join("'%s'" % k for k in known_keys))
41394149

@@ -4189,15 +4199,14 @@ def _sanity_check_step_common(self, custom_paths, custom_commands, is_extension=
41894199

41904200
return paths, path_keys_and_check, commands
41914201

4192-
def _sanity_check_step_dry_run(self, custom_paths=None, custom_commands=None, extension=False, **_):
4202+
def _sanity_check_step_dry_run(self, custom_paths=None, custom_commands=None, **_):
41934203
"""
41944204
Dry run version of sanity_check_step method.
41954205
41964206
:param custom_paths: custom sanity check paths to check existence for
41974207
:param custom_commands: custom sanity check commands to run
41984208
"""
4199-
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands,
4200-
is_extension=extension)
4209+
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands)
42014210

42024211
for key in [SANITY_CHECK_PATHS_FILES, SANITY_CHECK_PATHS_DIRS]:
42034212
(typ, _) = path_keys_and_check[key]
@@ -4292,7 +4301,7 @@ def sanity_check_load_module(self, extension=False, extra_modules=None):
42924301

42934302
return self.fake_mod_data
42944303

4295-
def _sanity_check_step(self, custom_paths=None, custom_commands=None, extension=False, extra_modules=None):
4304+
def _sanity_check_step(self, custom_paths=None, custom_commands=None, extra_modules=None):
42964305
"""
42974306
Real version of sanity_check_step method.
42984307
@@ -4301,8 +4310,7 @@ def _sanity_check_step(self, custom_paths=None, custom_commands=None, extension=
43014310
:param extension: indicates whether or not sanity check is run for an extension
43024311
:param extra_modules: extra modules to load before running sanity check commands
43034312
"""
4304-
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands,
4305-
is_extension=extension)
4313+
paths, path_keys_and_check, commands = self._sanity_check_step_common(custom_paths, custom_commands)
43064314

43074315
# helper function to sanity check (alternatives for) one particular path
43084316
def check_path(xs, typ, check_fn):
@@ -4359,7 +4367,7 @@ def xs2str(xs):
43594367
trace_msg("%s %s found: %s" % (typ, xs2str(xs), ('FAILED', 'OK')[found]))
43604368

43614369
if not self.sanity_check_module_loaded:
4362-
self.sanity_check_load_module(extension=extension, extra_modules=extra_modules)
4370+
self.sanity_check_load_module(extension=self.is_extension, extra_modules=extra_modules)
43634371

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

43904398
# also run sanity check for extensions (unless we are an extension ourselves)
4391-
if not extension:
4399+
if not self.is_extension:
43924400
if build_option('skip_extensions'):
43934401
self.log.info("Skipping sanity check for extensions since skip-extensions is enabled...")
43944402
else:
@@ -4440,7 +4448,7 @@ def xs2str(xs):
44404448
# pass or fail
44414449
if not self.sanity_check_fail_msgs:
44424450
self.log.debug("Sanity check passed!")
4443-
elif not extension:
4451+
elif not self.is_extension:
44444452
raise EasyBuildError(
44454453
"Sanity check failed: " + '\n'.join(self.sanity_check_fail_msgs),
44464454
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)