diff --git a/cylc/flow/cfgspec/globalcfg.py b/cylc/flow/cfgspec/globalcfg.py index 4988da885e2..46ed582f10b 100644 --- a/cylc/flow/cfgspec/globalcfg.py +++ b/cylc/flow/cfgspec/globalcfg.py @@ -48,6 +48,7 @@ Range, cylc_config_validate, ) +from cylc.flow.run_modes import JOBLESS_MODES PLATFORM_REGEX_TEXT = ''' @@ -1887,6 +1888,13 @@ def default_for( def upg(cfg, descr): """Upgrader.""" u = upgrader(cfg, descr) + for platform in JOBLESS_MODES: + u.forbid( + ['platforms', platform], + GlobalConfigError, + f'Platform name "{platform}" is not permitted.', + is_section=True, + ) u.upgrade() diff --git a/cylc/flow/parsec/upgrade.py b/cylc/flow/parsec/upgrade.py index 3ef53b006f6..8e189d87bda 100644 --- a/cylc/flow/parsec/upgrade.py +++ b/cylc/flow/parsec/upgrade.py @@ -80,7 +80,13 @@ def deprecate( 'silent': silent, 'is_section': is_section }) - def obsolete(self, vn, oldkeys, silent=False, is_section=False): + def obsolete( + self, + vn, + oldkeys, + silent: bool = False, + is_section: bool = False, + ): """Remove an obsolete key from a config Args: vn (str): @@ -89,18 +95,57 @@ def obsolete(self, vn, oldkeys, silent=False, is_section=False): Path within config to be removed. silent: Set silent mode for this upgrade. - is_section (bool): + is_section: Is a section heading. + hard_error: + Raise an error _NOW_. """ if vn not in self.upgrades: self.upgrades[vn] = [] - cvtr = converter(lambda x: x, "DELETED (OBSOLETE)") # identity + else: + cvtr = converter(lambda x: x, "DELETED (OBSOLETE)") # identity self.upgrades[vn].append( { 'old': oldkeys, 'new': None, 'cvt': cvtr, 'silent': silent, 'is_section': is_section }) + def forbid( + self, + oldkeys, + error: Exception, + message: str, + is_section: bool = False, + ): + """Disallow a subset of arguments. + Args: + vn (str): + Version at which this obsoletion occurs. + oldkeys (list): + Path within config to be removed. + silent: + Set silent mode for this upgrade. + is_section: + Is a section heading. + hard_error: + Raise an error _NOW_. + """ + if 'forbidden' not in self.upgrades: + self.upgrades['forbidden'] = [] + + def callback(_): + raise error(message) + + self.upgrades['forbidden'].append( + { + 'old': oldkeys, + 'new': None, + 'cvt': converter(callback, ''), + 'silent': False, + 'is_section': is_section, + } + ) + def get_item(self, keys): item = self.cfg for key in keys: