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

Added warning for 'series:' instead of 'test_sets:' in series file. #672

Merged
merged 3 commits into from
Aug 9, 2023
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/tutorials/writing_a_series.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tests that are normally run just to make sure the machine works.

# This is the body of the series file. This is where we define test sets,
# which are groups of tests that we want to apply the same configurations to.
series:
test_sets:

# We'll call this test set 'front_end_tests' and run all the tests that
# don't run on compute nodes with this set.
Expand Down
15 changes: 11 additions & 4 deletions lib/pavilion/series_config/file_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,16 @@ class SeriesConfigLoader(yc.YamlConfigLoader):
'ignore_errors', default=True,
help_text="Whether the series ignores build and/or scheduling errors."
),
yc.StrElem(
'restart', post_validator=make_invalidator(
"The series config option 'restart' has been replaced with 'repeat'.")
)
yc.DiscontinuedElem(
'series',
help_text="Series parts are now configured under the 'test_sets' key in an effort "
"to reduce overloading of names. The keys under 'test_sets' are the same "
"as they were under the 'series' key, so all you should need to do is "
"change 'series:' to 'test_sets:'."
),
yc.DiscontinuedElem(
'restart',
help_text="The series config option 'restart' has been replaced with 'repeat'."
),
]
"""Describes elements in Series Config Loader."""
1 change: 1 addition & 0 deletions lib/yaml_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class BirthdayPartyConfig(yc.YamlConfigLoader):
ConfigDict,
ConfigElement,
RequiredError,
DiscontinuedElem,
)
from .loaders import (
CatYamlConfigLoader,
Expand Down
25 changes: 25 additions & 0 deletions lib/yaml_config/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
class RequiredError(ValueError):
pass

class DiscontinuedError(ValueError):
pass


class ConfigDict(dict):
"""Since we enforce field names that are also valid python names, we can
Expand Down Expand Up @@ -440,3 +443,25 @@ def merge(self, old, new, **kwargs):

def __repr__(self):
return "<yaml_config {} {}>".format(self.__class__.__name__, self.name)


class DiscontinuedElem(ConfigElement):
"""This element expects to never get a value. If a value other than
None is given, it throws a ValueError with a predefined warning to
the user."""

_type_name = 'Discontinued'

def __init__(self, name=None, hidden=True, help_text=""):

super().__init__(name=name, hidden=hidden, help_text=help_text)

def normalize(self, value, root_name='root'):
"""Throw an error if we get any value other than None."""

name = root_name if not self.name else self.name

if value is not None:
raise DiscontinuedError(
"Key '{}' is no longer valid: {}"
.format(name, self.help_text))
4 changes: 4 additions & 0 deletions lib/yaml_config/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .elements import (
ConfigElement,
RequiredError,
DiscontinuedError,
NullList,
ConfigDict,
)
Expand Down Expand Up @@ -517,6 +518,9 @@ def normalize(self, value, root_name=None):

try:
ndict[key] = elem.normalize(val, root_name=key)
except DiscontinuedError as err:
# This is thrown because the key is no longer allowed.
raise
except ValueError as err:
if isinstance(val, dict):
msg = [err.args[0]]
Expand Down
Loading