Skip to content

Conversation

marcodelapierre
Copy link
Contributor

Edits to use a dynamically defined moduleDir variable in all templates, rather than fixed {{ module_dir }}:

  • wrapper templates: location of env-file
  • modulefile templates
    • defining a local moduleDir variable
    • used for wrappers PATH, location of env-file, help output
    • both LUA and TCL
  • no more need to pass module_dir when rendering modulefile templates

Fix in wrapper base script:

  • for CSH shell, variables always need to be defined with set
  • note that export is not needed for bash shell, as the variable is only used directly in the wrapper script, not in any sub process
    • if willing to revert, then for consistency the CSH case needs setenv (can't recall the exact syntax)

Copy link
Member

@vsoch vsoch left a comment

Choose a reason for hiding this comment

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

Just a few small questions - and is there a way to test both of these?

-- we probably do not need this
local MODULEPATH="{{ module_dir }}"
-- directory containing this modulefile (dynamically defined)
local moduleDir = myFileName():match("(.*[/])") or "."
Copy link
Member

Choose a reason for hiding this comment

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

What is myFileName is that a function you are writing?

Copy link
Member

Choose a reason for hiding this comment

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

How does this work?

Copy link
Contributor Author

@marcodelapierre marcodelapierre Mar 2, 2022

Choose a reason for hiding this comment

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

No worries, so this is the very same syntax I had envisaged a couple of weeks ago for the dynamic moduleDir paths, and that we had discussed for use to define the PATH variable by the modulefiles.
The change is that here I am using it to define a Lua/Tcl variable, that can be re-used across the modulefile.

myFileName has the full path of the modulefile, and is documented in the Lmod docs: https://lmod.readthedocs.io/en/latest/050_lua_modulefiles.html
As for the match syntax, it is a generic Lua syntax, which I had found it across the internet (stack overflow or similar is the likely source).

I have tested it both in dummy Lua modulefiles, and by generating and testing production SHPC modulefiles.
Or do you mean tests to be implemented in the SHPC testing framework?

If it can help, I can lookup our old thread, and other links if relevant :)

@vsoch
Copy link
Member

vsoch commented Mar 2, 2022

@marcodelapierre
Copy link
Contributor Author

edits now done for module_dir in vanessa/salad/!

@vsoch vsoch merged commit 6f8c0c7 into singularityhub:add/wrapper-scripts Mar 2, 2022
@marcodelapierre marcodelapierre deleted the add/wrapper-scripts branch June 7, 2022 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants