Skip to content

Commit

Permalink
Merge pull request #3 from boegel/extension-run
Browse files Browse the repository at this point in the history
enhance install_extension_substep to support passing down (named) arguments
  • Loading branch information
lexming authored Feb 7, 2024
2 parents 6074b55 + e384579 commit c2298d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ def skip_extensions_parallel(self, exts_filter):
def install_extensions(self, *args, **kwargs):
"""[DEPRECATED] Install extensions."""
self.log.deprecated(
"Easyblock.install_extensions() is deprecated, use Easyblock.install_all_extensions() instead.",
"EasyBlock.install_extensions() is deprecated, use EasyBlock.install_all_extensions() instead.",
'6.0',
)
self.install_all_extensions(*args, **kwargs)
Expand Down Expand Up @@ -4479,7 +4479,7 @@ def copy_easyblocks_for_reprod(easyblock_instances, reprod_dir):
for easyblock_class in inspect.getmro(type(easyblock_instance)):
easyblock_path = inspect.getsourcefile(easyblock_class)
# if we reach EasyBlock, Extension or ExtensionEasyBlock class, we are done
# (Extension and ExtensionEasyblock are hardcoded to avoid a cyclical import)
# (Extension and ExtensionEasyBlock are hardcoded to avoid a cyclical import)
if easyblock_class.__name__ in [EasyBlock.__name__, 'Extension', 'ExtensionEasyBlock']:
break
else:
Expand Down
19 changes: 11 additions & 8 deletions easybuild/framework/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,41 +223,44 @@ def post_install_extension(self):
"""
self.master.run_post_install_commands(commands=self.cfg.get('postinstallcmds', []))

def install_extension_substep(self, substep):
def install_extension_substep(self, substep, *args, **kwargs):
"""
Carry out extension installation substep allowing use of deprecated
methods on those extensions using an older EasyBlock
"""
deprecated = {
substeps_mapping = {
'pre_install_extension': 'prerun',
'install_extension': 'run',
'install_extension_async': 'run_async',
'post_install_extension': 'postrun',
}

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

try:
ext_substep = getattr(self, deprecated[substep])
ext_substep = getattr(self, deprecated_method)
parent_obj = super(self.__class__, self)
parent_substep = getattr(parent_obj, deprecated[substep])
parent_substep = getattr(parent_obj, deprecated_method)
except AttributeError:
self.log.debug("Easyblock does not provide deprecated method for installation substep: %s", substep)
log_msg = f"EasyBlock does not implement deprecated method '{deprecated_method}' "
log_msg += f"for installation substep {substep}"
self.log.debug(log_msg)
ext_substep = getattr(self, substep)
else:
if ext_substep.__hash__() == parent_substep.__hash__():
# Deprecated method is present in parent, but no custom method in child Easyblock
ext_substep = getattr(self, substep)
else:
# Custom deprecated method used by child Easyblock
self.log.debug("Easyblock provides custom deprecated method for installation substep: %s", substep)
self.log.debug(f"EasyBlock provides custom deprecated method for installation substep: {substep}")
self.log.deprecated(
f"Extension.{deprecated[substep]}() is deprecated, use Extension.{substep}() instead.",
"6.0",
)

return ext_substep()
return ext_substep(*args, **kwargs)

def async_cmd_start(self, cmd, inp=None):
"""
Expand Down

0 comments on commit c2298d7

Please sign in to comment.