diff --git a/docs/tutorials/writing_a_series.rst b/docs/tutorials/writing_a_series.rst index d04abb545..a485b6be6 100644 --- a/docs/tutorials/writing_a_series.rst +++ b/docs/tutorials/writing_a_series.rst @@ -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. diff --git a/lib/pavilion/series_config/file_format.py b/lib/pavilion/series_config/file_format.py index 61172639c..259bb6c76 100644 --- a/lib/pavilion/series_config/file_format.py +++ b/lib/pavilion/series_config/file_format.py @@ -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.""" diff --git a/lib/yaml_config/__init__.py b/lib/yaml_config/__init__.py index 6d0a2380b..f634a68e6 100644 --- a/lib/yaml_config/__init__.py +++ b/lib/yaml_config/__init__.py @@ -70,6 +70,7 @@ class BirthdayPartyConfig(yc.YamlConfigLoader): ConfigDict, ConfigElement, RequiredError, + DiscontinuedElem, ) from .loaders import ( CatYamlConfigLoader, diff --git a/lib/yaml_config/elements.py b/lib/yaml_config/elements.py index 0c4ff5700..e928cd9d0 100644 --- a/lib/yaml_config/elements.py +++ b/lib/yaml_config/elements.py @@ -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 @@ -440,3 +443,25 @@ def merge(self, old, new, **kwargs): def __repr__(self): return "".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)) diff --git a/lib/yaml_config/structures.py b/lib/yaml_config/structures.py index f9e22345d..9a73399b3 100644 --- a/lib/yaml_config/structures.py +++ b/lib/yaml_config/structures.py @@ -7,6 +7,7 @@ from .elements import ( ConfigElement, RequiredError, + DiscontinuedError, NullList, ConfigDict, ) @@ -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]]