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

Setting MODULEPATH via config.yaml #353

Merged
merged 2 commits into from
Aug 3, 2023

Conversation

jo-basevi
Copy link
Collaborator

Add an option to add module directories to MODULEPATH via config.yaml.

Should close #347

@coveralls
Copy link

coveralls commented Aug 2, 2023

Coverage Status

coverage: 41.843% (+0.05%) from 41.798% when pulling 456a6d6 on jo-basevi:347-setting-module-use into c8e7424 on payu-org:master.

@jo-basevi
Copy link
Collaborator Author

So a simple solution could be to add a list of directories to add to the MODULEPATH, e.g. moduledirs
module use by default prepends to the MODULEPATH, and it doesn't add the directory if it is already in MODULEPATH.
So there could be ordering differences. For example, if prior to payu run:

$ module use dir1 
$ module use dir2 
$ echo $MODULEPATH 
dir2:dir1

And in config.yaml the order was

moduledirs:
    - dir2 
    - dir1

MODULEPATH with remain dir2:dir1 while if module use wasn't run before payu run, the order would be dir1:dir2

@jo-basevi
Copy link
Collaborator Author

jo-basevi commented Aug 2, 2023

I prefer a list of additional module directories than defining an entire MODULEPATH, however redefining MODULEPATH will have the benefit of a concretised order of directories
E.g. in config.yaml

env:
    MODULEPATH: /g/data/ik11/spack/0.20.1/share/modules/linux-rocky8-cascadelake:/g/data/hh5/public/modules:/etc/scl/modulefiles:/opt/Modules/modulefiles:/opt/Modules/v4.3.0/modulefiles:/apps/Modules/modulefiles

@jo-basevi
Copy link
Collaborator Author

jo-basevi commented Aug 2, 2023

It could be nice grouping the user-defined environment modules and modules directories together however that would add a breaking change to modules option..
e.g.

modules:
   use:
       - /g/data/ik11/spack/0.20.1/share/modules/linux-rocky8-cascadelake
   load:
       - parallelio/2.5.10-intel-2021.6.0

@aidanheerdegen
Copy link
Collaborator

It could be nice grouping the user-defined environment modules and modules directories together however that would add a breaking change to modules option

Agreed that does sound like nicest option.

It is possible to keep backward compatibility by testing the return value of popping the modules value off the config dictionary and updating it to the new syntax. This is how it was done when collate transitioned from a boolean to a dictionary of options:

payu/payu/fsops.py

Lines 80 to 82 in c8e7424

# Transform legacy collate config options
if type(collate_config) is bool:
collate_config = {'enable': collate_config}

@jo-basevi jo-basevi self-assigned this Aug 2, 2023
@jo-basevi jo-basevi force-pushed the 347-setting-module-use branch 2 times, most recently from 0e250dc to 3c5b4b2 Compare August 3, 2023 01:54
@jo-basevi
Copy link
Collaborator Author

Thanks for that suggestion @aidanheerdegen! I've added that in

@jo-basevi jo-basevi marked this pull request as ready for review August 3, 2023 02:42
Copy link
Collaborator

@aidanheerdegen aidanheerdegen left a comment

Choose a reason for hiding this comment

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

Looks good, but I do think we should add a few more tests for the additional functionality.

test/test_payu.py Outdated Show resolved Hide resolved
test/test_payu.py Show resolved Hide resolved
docs/source/config.rst Outdated Show resolved Hide resolved
Copy link
Collaborator

@aidanheerdegen aidanheerdegen left a comment

Choose a reason for hiding this comment

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

Looks good!

@jo-basevi
Copy link
Collaborator Author

Nothings changed/added, I just squashed the commits so it's a little cleaner

@jo-basevi jo-basevi merged commit 105fdc0 into payu-org:master Aug 3, 2023
5 checks passed
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.

Support setting MODULEPATH via config.yaml
3 participants