Skip to content

Commit

Permalink
config: suppress config deprecation warnings in compat mode
Browse files Browse the repository at this point in the history
* Configuration deprecation warnings are currently displayed in Cylc 7
  compatibility mode.
* Compatibility mode is expected to be used by Cylc 7/8 compatible
  workflows during this transition period.
* If users were to follow these warnings they would make their workflows
  incompatible with Cylc 7.
* This change suppresses these deprecation (and only deprecation)
  warnings in Cylc 7 compat mode.
  • Loading branch information
oliver-sanders committed Apr 20, 2022
1 parent 2d10d17 commit a0b7c0e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 39 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Third Release Candidate for Cylc 8 suitable for acceptance testing.

### Fixes

[#4829](https://github.com/cylc/cylc-flow/pull/4829) -
Suppress deprecated configuration warnings in Cylc 7 compatibility mode.

[#4554](https://github.com/cylc/cylc-flow/pull/4554) - Fix incorrect
implementation of the ISO 8601 recurrence format no. 1
(`R<number>/<start-point>/<second-point>`)
Expand Down
101 changes: 67 additions & 34 deletions cylc/flow/cfgspec/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from cylc.flow import LOG
from cylc.flow.cfgspec.globalcfg import EVENTS_DESCR, REPLACES
import cylc.flow.flags
from cylc.flow.parsec.exceptions import UpgradeError
from cylc.flow.parsec.config import ParsecConfig, ConfigNode as Conf
from cylc.flow.parsec.OrderedDict import OrderedDictWithDefaults
Expand Down Expand Up @@ -1631,7 +1632,14 @@ def get_script_common_text(this: str, example: Optional[str] = None):


def upg(cfg, descr):
"""Upgrade old workflow configuration."""
"""Upgrade old workflow configuration.
NOTE: We are silencing deprecation (and only deprecation) warnings
when in Cylc 7 compat mode to help support Cylc 7/8 compatible workflows
(which would loose Cylc 7 compatibility if users were to follow the
warnings and upgrade the syntax).
"""
u = upgrader(cfg, descr)
u.obsolete(
'7.8.0',
Expand Down Expand Up @@ -1668,60 +1676,76 @@ def upg(cfg, descr):
u.deprecate(
'8.0.0',
['cylc', 'task event mail interval'],
['cylc', 'mail', 'task event batch interval']
['cylc', 'mail', 'task event batch interval'],
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate(
'8.0.0',
['cylc', 'parameters'],
['task parameters'],
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate('8.0.0', ['cylc', 'parameters'], ['task parameters'])
u.deprecate(
'8.0.0',
['cylc', 'parameter templates'],
['task parameters', 'templates']
['task parameters', 'templates'],
silent=cylc.flow.flags.cylc7_back_compat,
)
# Whole workflow task mail settings
for mail_setting in ['to', 'from', 'footer']:
u.deprecate(
'8.0.0',
['cylc', 'events', f'mail {mail_setting}'],
['cylc', 'mail', mail_setting]
['cylc', 'mail', mail_setting],
silent=cylc.flow.flags.cylc7_back_compat,
)
# Task mail settings in [runtime][TASK]
for mail_setting in ['to', 'from']:
u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'events', f'mail {mail_setting}'],
['runtime', '__MANY__', 'mail', mail_setting]
['runtime', '__MANY__', 'mail', mail_setting],
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate(
'8.0.0',
['cylc', 'events', 'mail smtp'],
None, # This is really a .obsolete(), just with a custom message
cvtr=converter(lambda x: x, (
'DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" '
'instead'))
'instead')
),
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'events', 'mail smtp'],
None,
cvtr=converter(lambda x: x, (
'DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" '
'instead'))
'instead')
),
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate(
'8.0.0',
['scheduling', 'max active cycle points'],
['scheduling', 'runahead limit'],
cvtr=converter(lambda x: f'P{x}' if x != '' else '', '"n" -> "Pn"')
cvtr=converter(lambda x: f'P{x}' if x != '' else '', '"n" -> "Pn"'),
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate(
'8.0.0',
['scheduling', 'hold after point'],
['scheduling', 'hold after cycle point']
['scheduling', 'hold after cycle point'],
silent=cylc.flow.flags.cylc7_back_compat,
)

u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'suite state polling'],
['runtime', '__MANY__', 'workflow state polling'],
silent=cylc.flow.flags.cylc7_back_compat,
)

for job_setting in [
Expand All @@ -1734,7 +1758,8 @@ def upg(cfg, descr):
u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'job', job_setting],
['runtime', '__MANY__', job_setting]
['runtime', '__MANY__', job_setting],
silent=cylc.flow.flags.cylc7_back_compat,
)

# Workflow timeout is now measured from start of run.
Expand All @@ -1754,7 +1779,8 @@ def upg(cfg, descr):
u.deprecate(
'8.0.0',
['cylc', 'events', old],
['cylc', 'events', new]
['cylc', 'events', new],
silent=cylc.flow.flags.cylc7_back_compat,
)

for old in [
Expand All @@ -1776,7 +1802,8 @@ def upg(cfg, descr):
u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'events', old],
['runtime', '__MANY__', 'events', f"{old}s"]
['runtime', '__MANY__', 'events', f"{old}s"],
silent=cylc.flow.flags.cylc7_back_compat,
)

u.obsolete('8.0.0', ['cylc', 'events', 'abort on stalled'])
Expand All @@ -1787,7 +1814,12 @@ def upg(cfg, descr):
'abort if inactivity handler fails'])
u.obsolete('8.0.0', ['cylc', 'events', 'abort if stalled handler fails'])

u.deprecate('8.0.0', ['cylc'], ['scheduler'])
u.deprecate(
'8.0.0',
['cylc'],
['scheduler'],
silent=cylc.flow.flags.cylc7_back_compat,
)
u.upgrade()

upgrade_graph_section(cfg, descr)
Expand All @@ -1797,25 +1829,26 @@ def upg(cfg, descr):
warn_about_depr_event_handler_tmpl(cfg)

# Warn about config items moved to global.cylc.
if 'runtime' in cfg:
for job_setting, task in product(
[
'execution polling intervals',
'submission polling intervals',
'submission retry delays'
],
cfg['runtime'].keys()
):
if job_setting in cfg['runtime'][task]:
LOG.warning(
f"* (8.0.0) '[runtime][{task}]{job_setting}' - this "
"setting is deprecated; use "
f"'global.cylc[platforms][<platform name>]{job_setting}' "
"instead. "
"Currently, this item will override the corresponding "
"item in global.cylc, "
"but support for this will be removed in Cylc 9."
)
if not cylc.flow.flags.cylc7_back_compat:
if 'runtime' in cfg:
for job_setting, task in product(
[
'execution polling intervals',
'submission polling intervals',
'submission retry delays'
],
cfg['runtime'].keys()
):
if job_setting in cfg['runtime'][task]:
LOG.warning(
f"* (8.0.0) '[runtime][{task}]{job_setting}' - this "
"setting is deprecated; use "
"'global.cylc[platforms][<platform name>]"
f"{job_setting}' "
"instead. Currently, this item will override"
" the corresponding item in global.cylc, "
"but support for this will be removed in Cylc 9."
)


def upgrade_graph_section(cfg: Dict[str, Any], descr: str) -> None:
Expand Down Expand Up @@ -1845,7 +1878,7 @@ def upgrade_graph_section(cfg: Dict[str, Any], descr: str) -> None:
elif key == 'graph' and isinstance(value, str):
graphdict[key] = value
keys.add(key)
if keys:
if keys and not cylc.flow.flags.cylc7_back_compat:
LOG.warning(
'deprecated graph items were automatically upgraded '
f'in "{descr}":\n'
Expand Down
8 changes: 3 additions & 5 deletions cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,12 +781,10 @@ def _check_implicit_tasks(self) -> None:
)
# Allow implicit tasks in Cylc 7 back-compat mode (but not if
# rose-suite.conf present, to maintain compat with Rose 2019)
if (
Path(self.run_dir, 'rose-suite.conf').is_file() or
not cylc.flow.flags.cylc7_back_compat
):
if Path(self.run_dir, 'rose-suite.conf').is_file():
raise WorkflowConfigError(msg)
LOG.warning(msg)
if not cylc.flow.flags.cylc7_back_compat:
LOG.warning(msg)

def _check_circular(self):
"""Check for circular dependence in graph."""
Expand Down

0 comments on commit a0b7c0e

Please sign in to comment.