Skip to content

Conversation

@victorusu
Copy link
Contributor

@victorusu victorusu commented Jul 14, 2020

This PR extends the environment modules interface to include the module avail command.

This is the first step to allow the detection of modules to be included in the tests.

This PR adds the find_modules() utility function, which will retrieve all the available modules given a substring of a module name. Internally, it delegates to module avail substr of the current system's modules system, but it does so per system partition and respecting the ReFrame environments defined for each partition. It returns an iterator over a "set" of tuples of (partition, environment, module). This works nicely with hierarchical modules, but it can also work fine with flat modules scheme. In this case, you can pass a dictionary to the environ_mapping argument, which maps module names to ReFrame environments. This way, find_module() will skip any combinations of (partition, environment, module) that are not meaningful. You can use the return value of this function in parameterized tests as follows, in order to generate automatically tests for different modules. Here is an example:

@rfm.parameterized_test(*find_modules('netcdf'))
class MyTest(rfm.RegressionTest):
    def __init__(self, s, e, m):
        self.descr = f'{s}, {e}, {m}'
        self.valid_systems = [s]
        self.valid_prog_environs = [e]
        self.modules = [m]

For flat schemes you can use it as follows:

my_find_modules = functools.partial(find_modules, environ_mapping={
    r'.*CrayGNU.*': {'PrgEnv-gnu'},
    r'.*CrayIntel.*': {'PrgEnv-intel'},
    r'.*CrayCCE.*': {'PrgEnv-cray'}
})

@rfm.parameterized_test(*my_find_modules('GROMACS'))
class MyTest(rfm.RegressionTest):
    def __init__(self, s, e, m):
        self.descr = f'{s}, {e}, {m}'
        self.valid_systems = [s]
        self.valid_prog_environs = [e]
        self.modules = [m]

Fixes #1159.

Still todo:

  • Document the function and add a tutorial example
  • Better type checking of the toolchain_mapping argument

Future work:

find_modules() can be somewhat slow since it calls module avail for each partition/environment combination. We could in the future implement a caching mechanism on top of it.

@victorusu
Copy link
Contributor Author

@jenkins-cscs retry dom

victorusu and others added 2 commits July 15, 2020 13:16
Co-authored-by: Vasileios Karakasis <vkarak@gmail.com>
Co-authored-by: Vasileios Karakasis <vkarak@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Jul 15, 2020

Codecov Report

Merging #1417 into master will decrease coverage by 0.16%.
The diff coverage is 72.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1417      +/-   ##
==========================================
- Coverage   91.73%   91.57%   -0.17%     
==========================================
  Files          83       83              
  Lines       12886    12993     +107     
==========================================
+ Hits        11821    11898      +77     
- Misses       1065     1095      +30     
Impacted Files Coverage Δ
reframe/core/modules.py 60.36% <33.33%> (-1.59%) ⬇️
reframe/utility/__init__.py 91.55% <68.00%> (-1.43%) ⬇️
unittests/test_modules.py 76.96% <82.35%> (+0.20%) ⬆️
unittests/test_utility.py 99.39% <93.02%> (-0.36%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08d9f6b...2934213. Read the comment docs.

@vkarak vkarak removed this from the ReFrame sprint 20.11 milestone Jul 16, 2020
@pep8speaks
Copy link

pep8speaks commented Sep 4, 2020

Hello @victorusu, Thank you for updating!

Cheers! There are no PEP8 issues in this Pull Request!Do see the ReFrame Coding Style Guide

Comment last updated at 2020-09-22 19:26:46 UTC

@vkarak vkarak self-assigned this Sep 7, 2020
@vkarak vkarak changed the title [feat] Add module available to modules interface [feat] Add utility function to look for available environment modules Sep 9, 2020
@vkarak
Copy link
Contributor

vkarak commented Sep 9, 2020

@mboisson @davidedelvento

This PR should do pretty much what we have been discussing in #1159. Could you test it?

@vkarak vkarak marked this pull request as draft September 9, 2020 17:11
@mboisson
Copy link
Contributor

mboisson commented Sep 9, 2020

I'll have to put this on the pile. I haven't had time to touch our Reframe tests in months...

@vkarak
Copy link
Contributor

vkarak commented Sep 9, 2020

@jenkins-cscs retry all

@davidedelvento
Copy link

I've been very busy with other stuff too, but trying various aspects of ReFrame in NCAR's environment is at the top of my todo list, just after a couple of other things which are due by the end of the month. So I should get to it in early October, and perhaps sooner.
@vkarak Do you need/want feedback earlier that this?

@vkarak
Copy link
Contributor

vkarak commented Sep 10, 2020

@mboisson @davidedelvento I don't want to rush you, I just wanted to put that in your radar and test it whenever you have time. My plan is to merge this in the next weeks and ship it with ReFrame 3.2, but you can test it afterwards and we enhance it further.

@vkarak
Copy link
Contributor

vkarak commented Sep 18, 2020

@jenkins-cscs retry all

Vasileios Karakasis added 3 commits September 18, 2020 18:23
Also:

- Improve argument names.
- Improve type checking of the `environ_mapping` argument.
@vkarak vkarak marked this pull request as ready for review September 18, 2020 20:19
@vkarak vkarak requested a review from ekouts September 18, 2020 20:19
@victorusu
Copy link
Contributor Author

lgtm

@vkarak
Copy link
Contributor

vkarak commented Sep 22, 2020

@jenkins-cscs retry all

@vkarak vkarak merged commit b243aef into reframe-hpc:master Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parametrizing tests based on module discovery

7 participants