Skip to content

Commit

Permalink
First attempt at using a mixin class
Browse files Browse the repository at this point in the history
  • Loading branch information
Caspar van Leeuwen committed Sep 4, 2024
1 parent fbfe08d commit 3ae63d8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 15 deletions.
35 changes: 35 additions & 0 deletions eessi/testsuite/eessi_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from reframe.core.pipeline import RegressionMixin
from reframe.core.exceptions import ReframeSyntaxError

from eessi.testsuite import hooks

class EESSI_Mixin(RegressionMixin):
"""
All EESSI tests should derive from this mixin class unless they have a very good reason not to.
"""

# We have to make sure that these gets set in any test that inherits
# device_type = variable(str)
# scale = variable(str)
# module_name = variable(str)

@run_after('init')
def validate(self):
"""Check that all variables that have to be set for subsequent hooks in the init phase have been set"""
if not hasattr(self, 'device_type'):
raise ReframeSyntaxError("device_type should be defined in any class that inherits from EESSI_Mixin, but wasn't")


@run_after('init')
def run_after_init(self):
"""Hooks to run after init phase"""

# Filter on which scales are supported by the partitions defined in the ReFrame configuration
hooks.filter_supported_scales(self)

hooks.filter_valid_systems_by_device_type(self, required_device_type=self.device_type)

hooks.set_modules(self)

# Set scales as tags
hooks.set_tag_scale(self)
30 changes: 15 additions & 15 deletions eessi/testsuite/tests/apps/lammps/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

from eessi.testsuite import hooks, utils
from eessi.testsuite.constants import * # noqa
from eessi.testsuite.eessi_mixin import EESSI_Mixin


class EESSI_LAMMPS_base(rfm.RunOnlyRegressionTest):
class EESSI_LAMMPS_base(rfm.RunOnlyRegressionTest, EESSI_Mixin):
scale = parameter(SCALES.keys())
valid_prog_environs = ['default']
valid_systems = ['*']
Expand Down Expand Up @@ -47,19 +47,19 @@ def assert_run(self):

return sn.assert_eq(n_atoms, 32000)

@run_after('init')
def run_after_init(self):
"""hooks to run after init phase"""

# Filter on which scales are supported by the partitions defined in the ReFrame configuration
hooks.filter_supported_scales(self)

hooks.filter_valid_systems_by_device_type(self, required_device_type=self.device_type)

hooks.set_modules(self)

# Set scales as tags
hooks.set_tag_scale(self)
# @run_after('init')
# def run_after_init(self):
# """hooks to run after init phase"""
#
# # Filter on which scales are supported by the partitions defined in the ReFrame configuration
# hooks.filter_supported_scales(self)
#
# hooks.filter_valid_systems_by_device_type(self, required_device_type=self.device_type)
#
# hooks.set_modules(self)
#
# # Set scales as tags
# hooks.set_tag_scale(self)

@run_after('setup')
def run_after_setup(self):
Expand Down

0 comments on commit 3ae63d8

Please sign in to comment.