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 88b880b
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 48 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
1 change: 0 additions & 1 deletion cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,6 @@ def _check_implicit_tasks(self) -> None:
not cylc.flow.flags.cylc7_back_compat
):
raise WorkflowConfigError(msg)
LOG.warning(msg)

def _check_circular(self):
"""Check for circular dependence in graph."""
Expand Down
18 changes: 5 additions & 13 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,22 +1096,22 @@ def test_success_after_optional_submit(tmp_flow_config, graph):
]
)
@pytest.mark.parametrize(
'cylc7_compat, rose_suite_conf, expected_exc, expected_log_level',
'cylc7_compat, rose_suite_conf, expected_exc',
[
pytest.param(
False, False, WorkflowConfigError, None,
False, False, WorkflowConfigError,
id="Default"
),
pytest.param(
False, True, WorkflowConfigError, None,
False, True, WorkflowConfigError,
id="rose-suite.conf present"
),
pytest.param(
True, False, None, logging.WARNING,
True, False, None,
id="Cylc 7 back-compat"
),
pytest.param(
True, True, WorkflowConfigError, None,
True, True, WorkflowConfigError,
id="Cylc 7 back-compat, rose-suite.conf present"
),
]
Expand All @@ -1121,7 +1121,6 @@ def test_implicit_tasks(
cylc7_compat: bool,
rose_suite_conf: bool,
expected_exc: Optional[Type[Exception]],
expected_log_level: Optional[int],
caplog: pytest.LogCaptureFixture,
log_filter: Callable,
monkeypatch: pytest.MonkeyPatch,
Expand All @@ -1136,9 +1135,6 @@ def test_implicit_tasks(
rose_suite_conf: Whether a rose-suite.conf file is present in run dir.
expected_exc: Exception expected to be raised only when
"[scheduler]allow implicit tasks" is not set.
expected_log_level: Expected logging severity level for the
"implicit tasks detected" message only when
"[scheduler]allow implicit tasks" is not set.
"""
# Setup
reg = 'rincewind'
Expand All @@ -1158,7 +1154,6 @@ def test_implicit_tasks(
caplog.set_level(logging.DEBUG, CYLC_LOG)
if allow_implicit_tasks is True:
expected_exc = None
expected_log_level = logging.DEBUG
elif allow_implicit_tasks is False:
expected_exc = WorkflowConfigError
# Test
Expand All @@ -1170,9 +1165,6 @@ def test_implicit_tasks(
assert expected_msg in str(exc.value)
else:
WorkflowConfig(**args)
assert log_filter(
caplog, level=expected_log_level, contains=expected_msg
)


@pytest.mark.parametrize('workflow_meta', [True, False])
Expand Down

0 comments on commit 88b880b

Please sign in to comment.