Skip to content

Conversation

@vkarak
Copy link
Contributor

@vkarak vkarak commented Sep 28, 2019

This PR provides a mechanism around the low-level getdep() function that is used to access information on the dependencies of a test. The syntax follows the paradigm of the @run_before and @run_after decorators as introduced in #920. The following shows a more concrete example:

import reframe as rfm


@rfm.simple_test
class T0(rfm.RegressionTest):
    def __init__(self):
        ...
        self.x = 1

@rfm.simple_test
class T1(rfm.RegressionTest):
    def __init__(self):
        ...
        self.depends_on('T0')

     @rfm.require_deps
     def sety(self, T0):
        self.y = T0().x + 1

The @require_deps will bind all arguments of the decorated function to the corresponding test dependencies by name. In the above example, the T0 argument will be bound to the T0 test, so that its information can be retrieved when the function is executed. More precisely, each argument of the function (except self) is bound to functools.partial(self.getdep, arg_name). This allows to access a specific a test case of the target dependency as in the example below:

     @rfm.require_deps
     def sety(self, T0):
        self.y = T0('PrgEnv-gnu').x + 1

When no environment is passed to the bound argument, the self.current_environ is assumed.

All functions that require dependencies to be executed after dependency resolution will be executed first after the setup phase and before any other function that is set to run after setup using the @run_after('setup') decorator. You may also attach a function that requires dependencies to a different pipeline stage using as usual the @run_before or @run_after decorators as follows:

     @rfm.run_before('compile')
     @rfm.require_deps
     def sety(self, T0):
        self.y = T0().x + 1

The only requirement is that the @require_deps decorator is the innermost one. Of course, you can attach a function that requires dependencies to run before the setup() method, in which a runtime error will be generated.

Fixes UES-540.

@codecov-io
Copy link

codecov-io commented Sep 28, 2019

Codecov Report

Merging #951 into master will increase coverage by 0.01%.
The diff coverage is 96.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #951      +/-   ##
==========================================
+ Coverage   91.64%   91.66%   +0.01%     
==========================================
  Files          79       79              
  Lines       10492    10553      +61     
==========================================
+ Hits         9615     9673      +58     
- Misses        877      880       +3
Impacted Files Coverage Δ
reframe/core/pipeline.py 93.61% <100%> (-0.16%) ⬇️
unittests/test_pipeline.py 96.72% <100%> (+0.22%) ⬆️
unittests/test_policies.py 98.73% <100%> (+0.01%) ⬆️
reframe/core/meta.py 100% <100%> (ø) ⬆️
reframe/core/decorators.py 96.84% <81.81%> (-1.97%) ⬇️

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 8c43eec...dddd083. Read the comment docs.

@vkarak vkarak merged commit f552047 into reframe-hpc:master Oct 2, 2019
@vkarak vkarak deleted the feat/require_deps-syntax branch October 2, 2019 13:42
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.

3 participants