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

[feat] Allow partition/environment extras to be used also as feature constraints in valid_systems and valid_prog_environs #3316

Merged
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
4 changes: 3 additions & 1 deletion docs/config_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ System Partition Configuration
:required: No
:default: ``[]``

A list of job scheduler `resource specification <#custom-job-scheduler-resources>`__ objects.
A list of job scheduler :ref:`resource specification <scheduler-resources>` objects.


.. py:attribute:: systems.partitions.processor
Expand Down Expand Up @@ -747,6 +747,8 @@ ReFrame can launch containerized applications, but you need to configure properl
If specified in conjunction with :attr:`~systems.partitions.container_platforms.env_vars`, it will be ignored.


.. _scheduler-resources:

Custom Job Scheduler Resources
==============================

Expand Down
11 changes: 9 additions & 2 deletions reframe/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,18 @@ def pipeline_hooks(cls):
#: of the :attr:`valid_systems` list, in which case an AND operation on
#: these constraints is implied. For example, the test defining the
#: following will be valid for all systems that have define both ``feat1``
#: and ``feat2`` and set ``foo=1``
#: and ``feat2`` and set ``foo=1``:
#:
#: .. code-block:: python
#:
#: valid_systems = ['+feat1 +feat2 %foo=1']
#: valid_systems = [r'+feat1 +feat2 %foo=1']
#:
#: Any partition/environment extra or
#: :ref:`partition resource <scheduler-resources>` can be specified as a
#: feature constraint without having to explicitly state this in the
#: partition's/environment's feature list. For example, if ``key1`` is part
#: of the partition/environment extras list, then ``+key1`` will select
#: that partition or environment.
#:
#: For key/value pairs comparisons, ReFrame will automatically convert the
#: value in the key/value spec to the type of the value of the
Expand Down
11 changes: 7 additions & 4 deletions reframe/core/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,13 @@ def _is_valid_part(part, valid_systems):
props[key] = val

have_plus_feats = all(
ft in part.features or ft in part.resources
(ft in part.features or
ft in part.resources or ft in part.extras)
for ft in plus_feats
)
have_minus_feats = any(
ft in part.features or ft in part.resources
(ft in part.features or
ft in part.resources or ft in part.extras)
for ft in minus_feats
)
try:
Expand Down Expand Up @@ -357,8 +359,9 @@ def _is_valid_env(env, valid_prog_environs):
key, val = subspec[1:].split('=')
props[key] = val

have_plus_feats = all(ft in env.features for ft in plus_feats)
have_minus_feats = any(ft in env.features
have_plus_feats = all(ft in env.features or ft in env.extras
for ft in plus_feats)
have_minus_feats = any(ft in env.features or ft in env.extras
for ft in minus_feats)
try:
have_props = True
Expand Down
39 changes: 33 additions & 6 deletions unittests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def _assert_supported(valid_systems, valid_prog_environs,

# Check AND in features and extras
_assert_supported(
valid_systems=['+cuda +mpi %gpu_arch=v100'],
valid_systems=[r'+cuda +mpi %gpu_arch=v100'],
valid_prog_environs=['*'],
expected={}
)
Expand All @@ -566,9 +566,18 @@ def _assert_supported(valid_systems, valid_prog_environs,
expected={}
)

# Check OR in features ad extras
# Check OR in features and extras
_assert_supported(
valid_systems=['+cuda +mpi', '%gpu_arch=v100'],
valid_systems=['+cuda +mpi', r'%gpu_arch=v100'],
valid_prog_environs=['*'],
expected={
'testsys:gpu': ['PrgEnv-gnu', 'builtin']
}
)

# Check that extra keys can used as features
_assert_supported(
valid_systems=['+cuda +mpi', '+gpu_arch'],
valid_prog_environs=['*'],
expected={
'testsys:gpu': ['PrgEnv-gnu', 'builtin']
Expand Down Expand Up @@ -640,23 +649,23 @@ def _assert_supported(valid_systems, valid_prog_environs,
)
_assert_supported(
valid_systems=['*'],
valid_prog_environs=['%bar=x'],
valid_prog_environs=[r'%bar=x'],
expected={
'testsys:gpu': [],
'testsys:login': ['PrgEnv-gnu']
}
)
_assert_supported(
valid_systems=['*'],
valid_prog_environs=['%foo=2'],
valid_prog_environs=[r'%foo=2'],
expected={
'testsys:gpu': ['PrgEnv-gnu'],
'testsys:login': []
}
)
_assert_supported(
valid_systems=['*'],
valid_prog_environs=['%foo=bar'],
valid_prog_environs=[r'%foo=bar'],
expected={
'testsys:gpu': [],
'testsys:login': []
Expand All @@ -671,6 +680,24 @@ def _assert_supported(valid_systems, valid_prog_environs,
}
)

# Check that extra keys can used as features
_assert_supported(
valid_systems=['*'],
valid_prog_environs=['+foo +bar'],
expected={
'testsys:gpu': ['PrgEnv-gnu'],
'testsys:login': ['PrgEnv-gnu']
}
)
_assert_supported(
valid_systems=['*'],
valid_prog_environs=['+foo -bar'],
expected={
'testsys:gpu': [],
'testsys:login': []
}
)

# Check valid_systems / valid_prog_environs combinations
_assert_supported(
valid_systems=['testsys:login'],
Expand Down
Loading