Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modules: use depends-on to autoload module with Lmod on Tcl #38347

Merged
merged 1 commit into from
Jun 14, 2023

Conversation

xdelaruelle
Copy link
Contributor

Update Tcl modulefile template to use the depends-on command to autoload modules if Lmod is the current module tool.

Autoloading modules with module load command in Tcl modulefile does not work well for Lmod at some extend. An attempt to unload then load designated module is performed each time such command is encountered. It may lead to a load storm that may not end correctly with large number of module dependencies.

depends-on command should be used for Lmod instead of module load, as it checks if module is already loaded, and does not attempt to reload this module.

Lua modulefile template already uses depends_on command to autoload dependencies. Thus it is already considered that to use Lmod with Spack, it must support depends_on command (version 7.6+).

Environment Modules copes well with module load command to autoload dependencies (version 3.2+). depends-on command is supported starting version 5.1 (as an alias of prereq-all command) which was relased last year.

This change introduces a test to determine if current module tool that evaluates modulefile is Lmod. If so, autoload dependencies are defined with depends-on command. Otherwise module load command is used.

Test is based on LMOD_VERSION_MAJOR environment variable, which is set by Lmod starting version 5.1.

Fixes #36764

@spackbot-app spackbot-app bot added core PR affects Spack core functionality tests General test capability(ies) labels Jun 13, 2023
@xdelaruelle xdelaruelle requested a review from alalazo June 13, 2023 04:19
alalazo
alalazo previously approved these changes Jun 14, 2023
@@ -26,9 +26,15 @@ proc ModulesHelp { } {
{% endblock %}

{% block autoloads %}
if {![info exists ::env(LMOD_VERSION_MAJOR)]} {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second look, wouldn't this be creating an empty if/else statement if no autoload modules are present?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I need to check if there is something to autoload prior adding this if/else statement.

Copy link
Contributor Author

@xdelaruelle xdelaruelle Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reworked template to check if there are elements to autoload with {% if autoload|length > 0 %} condition.

I have also updated tests to add assertion checking if if {![info exists ::env(LMOD_VERSION_MAJOR)]} { condition is there or not.

@alalazo alalazo self-assigned this Jun 14, 2023
@alalazo alalazo mentioned this pull request Jun 14, 2023
23 tasks
Update Tcl modulefile template to use the `depends-on` command to
autoload modules if Lmod is the current module tool.

Autoloading modules with `module load` command in Tcl modulefile does
not work well for Lmod at some extend. An attempt to unload then load
designated module is performed each time such command is encountered. It
may lead to a load storm that may not end correctly with large number of
module dependencies.

`depends-on` command should be used for Lmod instead of `module load`,
as it checks if module is already loaded, and does not attempt to reload
this module.

Lua modulefile template already uses `depends_on` command to autoload
dependencies. Thus it is already considered that to use Lmod with Spack,
it must support `depends_on` command (version 7.6+).

Environment Modules copes well with `module load` command to autoload
dependencies (version 3.2+). `depends-on` command is supported starting
version 5.1 (as an alias of `prereq-all` command) which was relased last
year.

This change introduces a test to determine if current module tool that
evaluates modulefile is Lmod. If so, autoload dependencies are defined
with `depends-on` command. Otherwise `module load` command is used.

Test is based on `LMOD_VERSION_MAJOR` environment variable, which is set
by Lmod starting version 5.1.

Fixes spack#36764
@alalazo alalazo merged commit 2db09f2 into spack:develop Jun 14, 2023
@alalazo
Copy link
Member

alalazo commented Jun 14, 2023

Thanks!

@xdelaruelle xdelaruelle deleted the lmod_autoload_with_depends_on branch June 14, 2023 18:55
alalazo pushed a commit that referenced this pull request Jun 30, 2023
Update Tcl modulefile template to use the `depends-on` command to
autoload modules if Lmod is the current module tool.

Autoloading modules with `module load` command in Tcl modulefile does
not work well for Lmod at some extend. An attempt to unload then load
designated module is performed each time such command is encountered. It
may lead to a load storm that may not end correctly with large number of
module dependencies.

`depends-on` command should be used for Lmod instead of `module load`,
as it checks if module is already loaded, and does not attempt to reload
this module.

Lua modulefile template already uses `depends_on` command to autoload
dependencies. Thus it is already considered that to use Lmod with Spack,
it must support `depends_on` command (version 7.6+).

Environment Modules copes well with `module load` command to autoload
dependencies (version 3.2+). `depends-on` command is supported starting
version 5.1 (as an alias of `prereq-all` command) which was relased last
year.

This change introduces a test to determine if current module tool that
evaluates modulefile is Lmod. If so, autoload dependencies are defined
with `depends-on` command. Otherwise `module load` command is used.

Test is based on `LMOD_VERSION_MAJOR` environment variable, which is set
by Lmod starting version 5.1.

Fixes #36764
alalazo pushed a commit that referenced this pull request Jul 7, 2023
Update Tcl modulefile template to use the `depends-on` command to
autoload modules if Lmod is the current module tool.

Autoloading modules with `module load` command in Tcl modulefile does
not work well for Lmod at some extend. An attempt to unload then load
designated module is performed each time such command is encountered. It
may lead to a load storm that may not end correctly with large number of
module dependencies.

`depends-on` command should be used for Lmod instead of `module load`,
as it checks if module is already loaded, and does not attempt to reload
this module.

Lua modulefile template already uses `depends_on` command to autoload
dependencies. Thus it is already considered that to use Lmod with Spack,
it must support `depends_on` command (version 7.6+).

Environment Modules copes well with `module load` command to autoload
dependencies (version 3.2+). `depends-on` command is supported starting
version 5.1 (as an alias of `prereq-all` command) which was relased last
year.

This change introduces a test to determine if current module tool that
evaluates modulefile is Lmod. If so, autoload dependencies are defined
with `depends-on` command. Otherwise `module load` command is used.

Test is based on `LMOD_VERSION_MAJOR` environment variable, which is set
by Lmod starting version 5.1.

Fixes #36764
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core PR affects Spack core functionality modules tests General test capability(ies)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error loading Spack modules
2 participants