Skip to content

Commit c2298d7

Browse files
authored
Merge pull request #3 from boegel/extension-run
enhance install_extension_substep to support passing down (named) arguments
2 parents 6074b55 + e384579 commit c2298d7

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

easybuild/framework/easyblock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ def skip_extensions_parallel(self, exts_filter):
18671867
def install_extensions(self, *args, **kwargs):
18681868
"""[DEPRECATED] Install extensions."""
18691869
self.log.deprecated(
1870-
"Easyblock.install_extensions() is deprecated, use Easyblock.install_all_extensions() instead.",
1870+
"EasyBlock.install_extensions() is deprecated, use EasyBlock.install_all_extensions() instead.",
18711871
'6.0',
18721872
)
18731873
self.install_all_extensions(*args, **kwargs)
@@ -4479,7 +4479,7 @@ def copy_easyblocks_for_reprod(easyblock_instances, reprod_dir):
44794479
for easyblock_class in inspect.getmro(type(easyblock_instance)):
44804480
easyblock_path = inspect.getsourcefile(easyblock_class)
44814481
# if we reach EasyBlock, Extension or ExtensionEasyBlock class, we are done
4482-
# (Extension and ExtensionEasyblock are hardcoded to avoid a cyclical import)
4482+
# (Extension and ExtensionEasyBlock are hardcoded to avoid a cyclical import)
44834483
if easyblock_class.__name__ in [EasyBlock.__name__, 'Extension', 'ExtensionEasyBlock']:
44844484
break
44854485
else:

easybuild/framework/extension.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,41 +223,44 @@ def post_install_extension(self):
223223
"""
224224
self.master.run_post_install_commands(commands=self.cfg.get('postinstallcmds', []))
225225

226-
def install_extension_substep(self, substep):
226+
def install_extension_substep(self, substep, *args, **kwargs):
227227
"""
228228
Carry out extension installation substep allowing use of deprecated
229229
methods on those extensions using an older EasyBlock
230230
"""
231-
deprecated = {
231+
substeps_mapping = {
232232
'pre_install_extension': 'prerun',
233233
'install_extension': 'run',
234234
'install_extension_async': 'run_async',
235235
'post_install_extension': 'postrun',
236236
}
237237

238-
if substep not in deprecated:
238+
deprecated_method = substeps_mapping.get(substep)
239+
if deprecated_method is None:
239240
raise EasyBuildError("Unknown extension installation substep: %s", substep)
240241

241242
try:
242-
ext_substep = getattr(self, deprecated[substep])
243+
ext_substep = getattr(self, deprecated_method)
243244
parent_obj = super(self.__class__, self)
244-
parent_substep = getattr(parent_obj, deprecated[substep])
245+
parent_substep = getattr(parent_obj, deprecated_method)
245246
except AttributeError:
246-
self.log.debug("Easyblock does not provide deprecated method for installation substep: %s", substep)
247+
log_msg = f"EasyBlock does not implement deprecated method '{deprecated_method}' "
248+
log_msg += f"for installation substep {substep}"
249+
self.log.debug(log_msg)
247250
ext_substep = getattr(self, substep)
248251
else:
249252
if ext_substep.__hash__() == parent_substep.__hash__():
250253
# Deprecated method is present in parent, but no custom method in child Easyblock
251254
ext_substep = getattr(self, substep)
252255
else:
253256
# Custom deprecated method used by child Easyblock
254-
self.log.debug("Easyblock provides custom deprecated method for installation substep: %s", substep)
257+
self.log.debug(f"EasyBlock provides custom deprecated method for installation substep: {substep}")
255258
self.log.deprecated(
256259
f"Extension.{deprecated[substep]}() is deprecated, use Extension.{substep}() instead.",
257260
"6.0",
258261
)
259262

260-
return ext_substep()
263+
return ext_substep(*args, **kwargs)
261264

262265
def async_cmd_start(self, cmd, inp=None):
263266
"""

0 commit comments

Comments
 (0)