fix fake_module_environment
context manager: make sure that cleanup of fake module is always done, even if an error was raised
#4895
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a problem when
--parallel-extensions-install
is used when extensions are involved that can't actually be installed in parallel, like withPerl-5.34.1-GCCcore-11.3.0.eb
:EasyBuild will naively always try to install extensions in parallel when the
--parallel-extensions-install
configuration setting is enabled, and only give up on that when aNotImplementedError
is raised; seeEasyBlock.install_all_extensions
.A
NotImplementedError
will be raised by theinstall_extension_async
method for extensions other than R packages.We should probably look into changing that, and only start installing extensions in parallel (via
EasyBlock.install_extensions_parallel
) if all extensions that should be installed actually support it. If not, the extensions should just be installed sequentially (viaEasyBlock.install_extensions_sequential
).Doing that correctly requires additional work though, probably an extra method in
Extension
that declares whether installing in parallel is supported, or not.The acute problem here is that this leaves the environment in an inconsistent state, because the fake module that was loaded when the asynchronous installation of the 1st extension was being launched will not be cleaned up.
This makes Lmod quite unhappy as soon as an attempt is made to prepare the environment for the installation of the 2nd extension, see error above.
This fix in this PR makes sure that the fake module that was loaded is correctly cleaned up, and then there's no problem when the extensions are being installed.
edit: opened two issues to follow-up on things that were uncovered while working out this fix: