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

[enhancement] Improve naming of automatically generated tests #3265

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ By inspecting the generated script files, you will notice that ReFrame emits the
.. code-block:: bash
:caption: Run with the Docker compose setup.

cat /scratch/rfm-stage/output/pseudo-cluster/compute/gnu/stream_test_pseudo-cluster_compute_8de19aca/rfm_job.sh
cat /scratch/rfm-stage/output/pseudo-cluster/compute/gnu/stream_test_584fea5f/rfm_job.sh

.. code-block:: bash

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ services:

frontend:
image: slurm-reframe
build: examples/tutorial/dockerfiles/slurm-cluster/reframe
build:
context: examples/tutorial/dockerfiles/slurm-cluster/reframe
args:
REFRAME_REPO: reframe-hpc
REFRAME_TAG: develop
container_name: frontend
hostname: login
user: admin
Expand Down
4 changes: 2 additions & 2 deletions reframe/core/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ def __new__(metacls, name, bases, namespace, **kwargs):
'''

# Collect the loggable properties
loggable_props = []
namespace['_rfm_loggable_props'] = [
v.fget._rfm_loggable for v in namespace.values()
if hasattr(v, 'fget') and hasattr(v.fget, '_rfm_loggable')
Expand Down Expand Up @@ -816,7 +815,8 @@ def is_abstract(cls):
def variant_name(cls, variant_num=None):
'''Return the name of the test variant with a specific variant number.

:param variant_num: An integer in the range of ``[0, cls.num_variants)``.
:param variant_num: An integer in the range of
``[0, cls.num_variants)``.
'''

name = cls.__name__
Expand Down
21 changes: 19 additions & 2 deletions reframe/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,9 +1194,26 @@ def unique_name(self):
def name(self):
'''The name of the test.

This is an alias of :attr:`display_name`.
This is an alias of :attr:`display_name` but omitting any implicit
parameters starting with ``$`` that are inserted by the
:option:`--repeat`, :option:`--distribute` and other similar options.

.. versionchanged:: 4.7

The implicit parameters starting with ``$`` are now omitted.
'''
return self.display_name
if hasattr(self, '_rfm_name'):
return self._rfm_name

# Remove any special parameters starting with `$`
basename, *params = self.display_name.split(' ')
name = basename
for p in params:
if not p.startswith('%$'):
name += f' {p}'

self._rfm_name = name
return self._rfm_name

@loggable
@property
Expand Down
5 changes: 3 additions & 2 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,15 @@ def describe_checks(testcases, printer):
if tc.check.is_fixture():
continue

if tc.check.name not in unique_names:
unique_names.add(tc.check.name)
if tc.check.display_name not in unique_names:
unique_names.add(tc.check.display_name)
rec = json.loads(jsonext.dumps(tc.check))

# Now manipulate the record to be more user-friendly
#
# 1. Add other fields that are relevant for users
# 2. Remove all private fields
rec['name'] = tc.check.name
rec['unique_name'] = tc.check.unique_name
rec['display_name'] = tc.check.display_name
rec['pipeline_hooks'] = {}
Expand Down
3 changes: 0 additions & 3 deletions reframe/frontend/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import re

from reframe.core.exceptions import ReframeError
from reframe.core.runtime import runtime


def re_compile(patt):
Expand All @@ -22,7 +21,6 @@ def _have_name(patt):
def _fn(case):
# Match pattern, but remove spaces from the `display_name`
display_name = case.check.display_name.replace(' ', '')
rt = runtime()
if '@' in patt:
# Do an exact match on the unique name
return patt.replace('@', '_') == case.check.unique_name
Expand All @@ -43,7 +41,6 @@ def _fn(case):


def have_any_name(names):
rt = runtime()
variant_matches = []
hash_matches = []
regex_matches = []
Expand Down
24 changes: 14 additions & 10 deletions reframe/frontend/testgenerators.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,16 @@ def _rfm_set_valid_systems(obj):
obj.valid_systems = [partition.fullname]

return make_test(
f'{cls.__name__}_{partition.fullname.replace(":", "_")}',
(cls,),
cls.__name__, (cls,),
{
'valid_systems': [partition.fullname],
# We add a partition parameter so as to differentiate the test
# in case another test has the same nodes in another partition
'$part': builtins.parameter([partition.fullname],
loggable=False),
'$nid': builtins.parameter(
[[n] for n in node_map[partition.fullname]],
fmt=util.nodelist_abbrev
fmt=util.nodelist_abbrev, loggable=False
)
},
methods=[
Expand All @@ -110,7 +113,7 @@ def _rfm_set_valid_systems(obj):
# will not be overwritten by a parent post-init hook
builtins.run_after('init')(_rfm_set_valid_systems),
]
), ['$nid']
), ['$part', '$nid']

return _generate_tests(testcases, _make_dist_test)

Expand All @@ -122,9 +125,10 @@ def repeat_tests(testcases, num_repeats):
def _make_repeat_test(testcase):
cls = type(testcase.check)
return make_test(
f'{cls.__name__}', (cls,),
cls.__name__, (cls,),
{
'$repeat_no': builtins.parameter(range(num_repeats))
'$repeat_no': builtins.parameter(range(num_repeats),
loggable=False)
}
), ['$repeat_no']

Expand All @@ -150,25 +154,25 @@ def _make_parameterized_test(testcase):
if var_check != cls.__name__:
continue
else:
getlogger().warning(f'cannot set a variable in a fixture')
getlogger().warning('cannot set a variable in a fixture')
continue

if not var in cls.var_space:
if var not in cls.var_space:
getlogger().warning(
f'variable {var!r} not defined for test '
f'{check.display_name!r}; ignoring parameterization'
)
continue

body[f'${var}'] = builtins.parameter(values)
body[f'${var}'] = builtins.parameter(values, loggable=False)

def _set_vars(self):
for var in body.keys():
setattr(self, var[1:],
make_convertible(getattr(self, f'{var}')))

return make_test(
f'{cls.__name__}', (cls,),
cls.__name__, (cls,),
body=body,
methods=[builtins.run_after('init')(_set_vars)]
), body.keys()
Expand Down
Loading