Skip to content

Commit

Permalink
Added warning for 'series:' instead of 'test_sets:' in series file. (#…
Browse files Browse the repository at this point in the history
…672)

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

* Update file_format.py
  • Loading branch information
Paul-Ferrell authored Aug 9, 2023
1 parent 08eb050 commit 4bd52e9
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
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

0 comments on commit 4bd52e9

Please sign in to comment.