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

Add a architecture env variable to the user subdir module path. #2330

Conversation

akesandgren
Copy link
Contributor

On systems with multiple architectures sharing a single home directory
for the users there need to be a way to install architecture specific
builds when using the subdir-user-modules extension.

On systems with multiple architectures sharing a single home directory
for the users there need to be a way to install architecture specific
builds when using the subdir-user-modules extension.
@boegelbot
Copy link

Travis test report: 9/9 runs failed - see https://travis-ci.org/easybuilders/easybuild-framework/builds/290804221

Only showing partial log for 1st failed test suite run 1481.1;
full log at https://travis-ci.org/easybuilders/easybuild-framework/jobs/290804222

...
travis_time:start:09fae331
�[0K$ python -O -m test.framework.suite
INFO: This is (based on) vsc.install.shared_setup 0.10.26
WARNING: xmlrunner module not available, falling back to using unittest...

......Deprecated functionality, will no longer work in v10000000000000: almost kaput; see http://easybuild.readthedocs.org/en/latest/Deprecated-functionality.html for more information
Deprecated functionality, will no longer work in v10000000000000: almost kaput; see http://easybuild.readthedocs.org/en/latest/Deprecated-functionality.html for more information
Deprecated functionality, will no longer work in v10000000000000: almost kaput; see http://easybuild.readthedocs.org/en/latest/Deprecated-functionality.html for more information
Deprecated functionality, will no longer work in v10000000000000: almost kaput; see http://easybuild.readthedocs.org/en/latest/Deprecated-functionality.html for more information
Deprecated functionality, will no longer work in v10000000000000: almost kaput; see http://easybuild.readthedocs.org/en/latest/Deprecated-functionality.html for more information
..........Skipping test_check_style, since pep8 is not available
...........Skipping test_empty_pr, no GitHub token available?
.......Skipping test_from_pr, no GitHub token available?
.Skipping test_from_pr, no GitHub token available?
.Skipping test_from_pr_x, no GitHub token available?
..................Skipping test_merge_pr, no GitHub token available?
...Skipping test_new_pr_delete, no GitHub token available?
.Skipping test_new_pr_dependencies, no GitHub token available?
.Skipping test_new_update_pr, no GitHub token available?
........Skipping test_review_pr, no GitHub token available?
.........== backup of existing module file stored at /tmp/eb-FHw2nT/eb-BhFx2T/eb-W5SIFz/tmp2Q58LH/modules/all/toy/0.0.lua.bak_20171021120730
== comparing module file with backup /tmp/eb-FHw2nT/eb-BhFx2T/eb-W5SIFz/tmp2Q58LH/modules/all/toy/0.0.lua.bak_20171021120730; no differences found
................(skipping SvnRepository test)
..................................................Deprecated functionality, will no longer work in v4.0: Named argument 'default_fallback' for get_easyblock_class is deprecated, use 'error_on_missing_easyblock' instead; see http://easybuild.readthedocs.org/en/latest/Deprecated-functionality.html for more information
......................................................................................................Failed to download https://pypi.python.org/simple/nosuchpackageonpypiever to determine available PyPI URLs for nosuchpackageonpypiever
...Skipping timeout test in test_download_file (working offline)
.............................................Skipping test_from_pr, no GitHub token available?
................== installing extension ext1  (1/1)...
..........F.......== installing extension ext1  (1/1)...
....Skipping test_download_repo, no GitHub token available?
.Skipping test_fetch_easyconfigs_from_pr, no GitHub token available?
.Skipping test_fetch_latest_commit_sha, no GitHub token available?
.Skipping test_find_easybuild_easyconfig, no GitHub token available?
..Skipping test_install_github_token, no GitHub token available?
.Skipping test_read, no GitHub token available?
.Skipping test_read_api, no GitHub token available?
.Skipping test_validate_github_token, no GitHub token available?
.Skipping test_walk, no GitHub token available?
..........................................
WARNING: Found one or more non-allowed loaded (EasyBuild-generated) modules in current environment:
* toy/0.0-external-deps

This is not recommended since it may affect the installation procedure(s) performed by EasyBuild.

To make EasyBuild allow particular loaded modules, use the --allow-loaded-modules configuration option.
To specify action to take when loaded modules are detected, use --detect-loaded-modules={error,ignore,purge,unload,warn}.

See http://easybuild.readthedocs.io/en/latest/Detecting_loaded_modules.html for more information.


WARNING: Found one or more non-allowed loaded (EasyBuild-generated) modules in current environment:
* toy/0.0-external-deps

This is not recommended since it may affect the installation procedure(s) performed by EasyBuild.

To make EasyBuild allow particular loaded modules, use the --allow-loaded-modules configuration option.
To specify action to take when loaded modules are detected, use --detect-loaded-modules={error,ignore,purge,unload,warn}.

See http://easybuild.readthedocs.io/en/latest/Detecting_loaded_modules.html for more information.


WARNING: Found one or more non-allowed loaded (EasyBuild-generated) modules in current environment:
* toy/0.0-external-deps

This is not recommended since it may affect the installation procedure(s) performed by EasyBuild.

To make EasyBuild allow particular loaded modules, use the --allow-loaded-modules configuration option.
To specify action to take when loaded modules are detected, use --detect-loaded-modules={error,ignore,purge,unload,warn}.

See http://easybuild.readthedocs.io/en/latest/Detecting_loaded_modules.html for more information.

.....== backup of existing module file stored at /tmp/eb-FHw2nT/eb-BhFx2T/eb-lz12ZF/tmpVIAX6H/modules/all/toy/0.0.lua.bak_20171021121158
== comparing module file with backup /tmp/eb-FHw2nT/eb-BhFx2T/eb-lz12ZF/tmpVIAX6H/modules/all/toy/0.0.lua.bak_20171021121158; no differences found
...............== backup of existing module file stored at /tmp/eb-FHw2nT/eb-BhFx2T/eb-VsBj_9/tmpSwgcbI/modules/all/toy/0.0.lua.bak_20171021121241
== comparing module file with backup /tmp/eb-FHw2nT/eb-BhFx2T/eb-VsBj_9/tmpSwgcbI/modules/all/toy/0.0.lua.bak_20171021121241; no differences found
..........................................................................................................................
======================================================================
FAIL: Test for make_module_extend_modpath
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/290804222/lib/python2.6/site-packages/easybuild_framework-3.5.0.dev0-py2.6.egg/test/framework/easyblock.py", line 221, in test_make_module_extend_modpath
    self.assertTrue(regex.search(txt), "Pattern '%s' found in: %s" % (regex.pattern, txt))
AssertionError: Pattern 'if isDir\(pathJoin\(os.getenv\("HOME"\), "my/own/modules/funky/Compiler/pi/3.14"\)\) then' found in: prepend_path("MODULEPATH", "/tmp/eb-FHw2nT/eb-BhFx2T/eb-zTGm16/tmpvKGbVv/modules/funky/Compiler/pi/3.14/compiler")
prepend_path("MODULEPATH", "/tmp/eb-FHw2nT/eb-BhFx2T/eb-zTGm16/tmpvKGbVv/modules/funky/Compiler/pi/3.14/tools")
if isDir(pathJoin(os.getenv("HOME"), pathJoin(pathJoin("my/own/modules", "funky"), "Compiler/pi/3.14"))) then
    prepend_path("MODULEPATH", pathJoin(os.getenv("HOME"), pathJoin(pathJoin("my/own/modules", "funky"), "Compiler/pi/3.14")))
end


----------------------------------------------------------------------
Ran 523 tests in 471.102s

FAILED (failures=1)
ERROR: Not all tests were successful.
Log available at /tmp/eb-FHw2nT/eb-BhFx2T/easybuild-tests-A1jj9T.log 

(bleep, bloop, I'm just a bot, please talk to my owner @boegel if you notice you me acting stupid)

@ocaisa
Copy link
Member

ocaisa commented Oct 21, 2017

Can't you just be clever in how you construct the user subdirectory path? Something like
$HOME/.local/$ARCH/EasyBuild, I don't really understand why you'd need another setting for this.

@boegel
Copy link
Member

boegel commented Oct 21, 2017

@ocaisa I think the problem is that you can't use $ARCH in an EasyBuild configuration file. This wouldn't be needed when you're configuring EasyBuild via $EASYBUILD_SUBDIR_USER_MODULES.

@akesandgren I feel the solution here is a bit too specific. If the problem is indeed that you can't use environment variables in an EasyBuild configuration file, then we should try to solve that in a general way?

@boegel boegel added this to the 3.5.0 milestone Oct 21, 2017
@akesandgren
Copy link
Contributor Author

akesandgren commented Oct 21, 2017

Yes that might be better, but remember that it needs to work for both Tcl and Lua modules.
I don't think there is a way you can do that correctly from the easyconfig.

The problem is that the env variable needs to be resolved when the user loads modules and not when EB creates the modules.

@akesandgren
Copy link
Contributor Author

akesandgren commented Oct 24, 2017

In case the problem description is unclear.

The user initiated EB build/install needs to have a separate path for each architecture at our site.
The SoftInst module we have in place that sets up the correct environment for the users can take care of this from the user side, i.e. $userprefix/software/$somearch, $userprefix/modules/$somearch/all etc or similar.

The problem is that the system installed modules need to get the extra "module use" (actually prepend_path("MODULEPATH", "some-user-prefix") with Lua) correct and resolvable at module load time. I.e. it must look something like:

if isDir(pathJoin(os.getenv("HOME"), "Public/easybuild/modules", os.getenv("SYSTEM_ARCH"), "all", "Compiler/GCCcore/6.4.0")) then
    prepend_path("MODULEPATH", pathJoin(os.getenv("HOME"), "Public/easybuild/modules", os.getenv("SYSTEM_ARCH"), "all", "Compiler/GCCcore/6.4.0")) 
end

where we have this in our site-wide easyconfig.cfg

subdir-user-modules=Public/easybuild/modules

I.e. one easyconfig.cfg for all systems.

@boegel
Copy link
Member

boegel commented Oct 24, 2017

The problem is that the env variable needs to be resolved when the user loads modules and not when EB creates the modules.

@akesandgren OK, I overlooked that, that's indeed quite important, since that implies that Tcl or Lua needs to grab the value of the environment variable when the module is being processed, so this is orthogonal to supporting the use of environment variables in EasyBuild configuration files...

@akesandgren
Copy link
Contributor Author

So, with that in mind is this at least in an acceptable direction?
Or do we need to find some other way?

@boegel
Copy link
Member

boegel commented Oct 24, 2017

@akesandgren I think the general direction is OK, but what you came up with for now is not flexible enough...

You're enforcing that only one single variable can be used, and the order of the subdir and the variable is fixed. I think we can do better.

I was thinking about coming up with a clear/safe syntax to express that the specified value for --subdir-user-modules contains a part that needs to be replaced with the value of an env var at 'runtime'. For example, something like Public/easybuild/modules/::ENV::SYSTEM_ARCH::. The ::ENV::*:: part could then indicate the part that needs to be translated in os.getenv("SYSTEM_ARCH") in a Lua module.

Transforming the provided string into the correct syntax for combining the static part(s) with the 'dynamic' part(s) (each determined by an env var to resolve) could be done by a new method in ModuleGenerator (e.g. parse_path_spec or something like that) to avoid having to pass everything down like you did now.

Am I making any sense?

@akesandgren
Copy link
Contributor Author

Yes, it makes sense. Not sure if you actually meant to put a " " in there but that's details...

And then doing $SOME_VAR in the easyconfig could be dealt with separately? For when you want it resolved at eb runtime.

@boegel
Copy link
Member

boegel commented Oct 24, 2017

@akesandgren I certainly did not mean to include a space in there (edited my comment above to remove it).

And yes, supporting the use of environment variables in EasyBuild configuration files (not easyconfigs, that's something else ;)), is an issue entirely separate from this, since it doesn't help with your use case at all.

@akesandgren
Copy link
Contributor Author

akesandgren commented Oct 25, 2017

the current module_generator.use code does quote the path argument, which won't work well with having a possible os.getenv("xx") in it though. So that part would then need to be moved to the caller(s), and there is probably more things to consider here.

@boegel
Copy link
Member

boegel commented Oct 25, 2017

@akesandgren We could still do the quoting in use, but only if the path is a string. If the path is a tuple, we can interpret that as having to wrap it in pathJoin(...) (and not quote).

BTW, we briefly discussed this during today's conf call, see https://github.com/easybuilders/easybuild/wiki/Conference-call-notes-20171025#support-use-of-environment-variables-in---subdir-user-modules .

Rather than using ::ENV::NAME:: as syntax for --subdir-user-modules to indicate environment variables that need to be resolved by the module itself, we can use a more natural syntax like ${NAME}.

Two downsides to that:

  • It opens up the possibility of accidentally letting ${NAME} be resolved too early, resulting in hardcoding the value for $NAME from the current session rather than letting the module pull it from the environment.
  • It complicates things a bit w.r.t. defining subdir-user-modules in an EasyBuild configuration file, keeping in mind that we may support the use of environment variables that do need to be resolved by eb itself at some point. We need to take that into account now, since we need a way to indicate that in subdir-user-mdoules the ${...} should NOT be resolved (and worse, maybe some part of the specified value should).

@boegel boegel modified the milestones: 3.5.0, next release Dec 6, 2017
@boegel boegel modified the milestones: 3.5.1, 3.6.0 Jan 12, 2018
@boegel
Copy link
Member

boegel commented Feb 1, 2018

@akesandgren After discussing this with you:

  • it would be nice to have support for grabbing values from environment variables when parsing easyconfig files; for this, we could extend the templating we have to support something like %(env:HOME)s which tells eb to grab $HOME value from the environment when parsing the easyconfig

  • the other thing is to have a way to specify that a particular env var should be resolved at runtime in the module (when the module is being loaded), not when the module is generated with eb; that could be supported something like:

eb --subdir-user-modules='Public/easybuild/modules/{RUNTIME_ENV::SYSTEM_ARCH}' ...

which would be equivalent (as module load time) with using Public/easybuild/modules/example iff $SYSTEM_ARCH = example

@akesandgren
Copy link
Contributor Author

I hope we can limit this to {RUNTIME_ENV::SYSTEM_ARCH} being surrounded only by "/", i.e. os.path.sep characters?
As in not allowing things like "Public/xx_{RUNTIME_ENV::SYSTEM_ARCH}_yy which would make this a lot more complicated to put back into decent Lua or Tcl code.

ebagrenrut and others added 24 commits February 7, 2018 12:50
…s 4+ behaves similarly to ModulesC, so also append GCCcore/6.2.0 if we are an instance of EnvironmentModules
Examples: 'GCCcore', 'icc', 'ifort'. They will be considered before
the compiler family ('Intel', etc).
…mentModules and EnvironmentModulesTcl modules tool
…ommand is modulecmd.tcl

introduce a is_modulecmd_tcl_modulestcl def to make distinction between
old Modules-Tcl and Modules 4+.
Change from using a specific subdir_arch_env to expanding
"{RUNTIME_ENV::SOME_ENV_VAR}" into module runtime equivalences of
os.getenv("SOME_ENV_VAR")
@akesandgren
Copy link
Contributor Author

Crap.... made an incorrect pull at some stage...

@akesandgren
Copy link
Contributor Author

Closing this PR since i messed up. Opened PR #2395 instead.

@akesandgren akesandgren closed this Feb 7, 2018
@akesandgren akesandgren deleted the add-arch_env-to-subdir-user-module-path branch July 6, 2018 09:29
@easybuilders easybuilders deleted a comment from boegelbot Jul 10, 2018
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.

10 participants